Kaydet (Commit) d4810a81 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

cosmetic 'en-passant'....

Change-Id: I9a787065898004ece4bd55839c563b7395e3a314
üst 7f554464
......@@ -27,9 +27,12 @@
namespace unoidl {
bool operator ==(ConstantValue const & lhs, ConstantValue const & rhs) {
if (lhs.type == rhs.type) {
switch (lhs.type) {
bool operator ==(ConstantValue const & lhs, ConstantValue const & rhs)
{
if (lhs.type == rhs.type)
{
switch (lhs.type)
{
case ConstantValue::TYPE_BOOLEAN:
return lhs.booleanValue == rhs.booleanValue;
case ConstantValue::TYPE_BYTE:
......@@ -55,12 +58,12 @@ bool operator ==(ConstantValue const & lhs, ConstantValue const & rhs) {
return false;
}
bool operator !=(ConstantValue const & lhs, ConstantValue const & rhs) {
bool operator !=(ConstantValue const & lhs, ConstantValue const & rhs)
{
return !(lhs == rhs);
}
bool operator ==(
SingleInterfaceBasedServiceEntity::Constructor::Parameter const & lhs,
bool operator ==( SingleInterfaceBasedServiceEntity::Constructor::Parameter const & lhs,
SingleInterfaceBasedServiceEntity::Constructor::Parameter const & rhs)
{
return lhs.name == rhs.name && lhs.type == rhs.type && lhs.rest == rhs.rest;
......@@ -70,12 +73,18 @@ bool operator ==(
namespace {
void badUsage() {
void badUsage()
{
std::cerr
<< "Usage:" << std::endl << std::endl
<< "Usage:"
<< std::endl
<< std::endl
<< (" unoidl-check [<extra registries A>] <registry A> -- [<extra"
" registries B>]")
<< std::endl << " <registry B>" << std::endl << std::endl
<< std::endl
<< " <registry B>"
<< std::endl
<< std::endl
<< ("where each <registry> is either a new- or legacy-format .rdb file,"
" a single .idl")
<< std::endl
......@@ -87,11 +96,14 @@ void badUsage() {
std::exit(EXIT_FAILURE);
}
OUString getArgumentUri(sal_uInt32 argument, bool * delimiter) {
OUString getArgumentUri(sal_uInt32 argument, bool * delimiter)
{
OUString arg;
rtl_getAppCommandArg(argument, &arg.pData);
if (arg == "--") {
if (delimiter == 0) {
if (arg == "--")
{
if (delimiter == 0)
{
badUsage();
}
*delimiter = true;
......@@ -99,15 +111,18 @@ OUString getArgumentUri(sal_uInt32 argument, bool * delimiter) {
}
OUString url;
osl::FileBase::RC e1 = osl::FileBase::getFileURLFromSystemPath(arg, url);
if (e1 != osl::FileBase::E_None) {
if (e1 != osl::FileBase::E_None)
{
std::cerr
<< "Cannot convert \"" << arg << "\" to file URL, error code "
<< +e1 << std::endl;
<< +e1
<< std::endl;
std::exit(EXIT_FAILURE);
}
OUString cwd;
oslProcessError e2 = osl_getProcessWorkingDir(&cwd.pData);
if (e2 != osl_Process_E_None) {
if (e2 != osl_Process_E_None)
{
std::cerr
<< "Cannot obtain working directory, error code " << +e2
<< std::endl;
......@@ -115,19 +130,21 @@ OUString getArgumentUri(sal_uInt32 argument, bool * delimiter) {
}
OUString abs;
e1 = osl::FileBase::getAbsoluteFileURL(cwd, url, abs);
if (e1 != osl::FileBase::E_None) {
if (e1 != osl::FileBase::E_None)
{
std::cerr
<< "Cannot make \"" << url
<< "\" into an absolute file URL, error code " << +e1 << std::endl;
<< "\" into an absolute file URL, error code " << +e1
<< std::endl;
std::exit(EXIT_FAILURE);
}
return abs;
}
OUString showDirection(
unoidl::InterfaceTypeEntity::Method::Parameter::Direction direction)
OUString showDirection( unoidl::InterfaceTypeEntity::Method::Parameter::Direction direction)
{
switch (direction) {
switch (direction)
{
case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN:
return OUString("[in]");
case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT:
......@@ -139,7 +156,8 @@ OUString showDirection(
}
}
struct EqualsAnnotation {
struct EqualsAnnotation
{
EqualsAnnotation(OUString const & name): name_(name) {}
bool operator ()(unoidl::AnnotatedReference const & ref)
......@@ -149,49 +167,52 @@ private:
OUString name_;
};
void checkMap(
rtl::Reference<unoidl::Provider> const & providerB, OUString const & prefix,
void checkMap( rtl::Reference<unoidl::Provider> const & providerB, OUString const & prefix,
rtl::Reference<unoidl::MapCursor> const & cursor)
{
assert(providerB.is());
assert(cursor.is());
for (;;) {
for (;;)
{
OUString id;
rtl::Reference<unoidl::Entity> entA(cursor->getNext(&id));
if (!entA.is()) {
if (!entA.is())
{
break;
}
OUString name(prefix + id);
if (entA->getSort() == unoidl::Entity::SORT_MODULE) {
checkMap(
providerB, name + ".",
(static_cast<unoidl::ModuleEntity *>(entA.get())
->createCursor()));
} else {
if (entA->getSort() == unoidl::Entity::SORT_MODULE)
{
checkMap( providerB, name + ".",
(static_cast<unoidl::ModuleEntity *>(entA.get())->createCursor()));
}
else
{
rtl::Reference<unoidl::Entity> entB(providerB->findEntity(name));
if (!entB.is()) {
if (!entB.is())
{
std::cerr
<< "A entity " << name << " is not present in B"
<< std::endl;
std::exit(EXIT_FAILURE);
}
if (entA->getSort() != entB->getSort()) {
if (entA->getSort() != entB->getSort())
{
std::cerr
<< "A entity " << name << " is of different sort in B"
<< std::endl;
std::exit(EXIT_FAILURE);
}
if ((dynamic_cast<unoidl::PublishableEntity *>(entA.get())
->isPublished())
&& (!dynamic_cast<unoidl::PublishableEntity *>(entB.get())
->isPublished()))
if ((dynamic_cast<unoidl::PublishableEntity *>(entA.get())->isPublished()) &&
(!dynamic_cast<unoidl::PublishableEntity *>(entB.get())->isPublished()))
{
std::cerr
<< "A published entity " << name << " is not published in B"
<< std::endl;
std::exit(EXIT_FAILURE);
}
switch (entA->getSort()) {
switch (entA->getSort())
{
case unoidl::Entity::SORT_MODULE:
assert(false && "this cannot happen");
//deliberate fall-through anyway
......@@ -201,14 +222,15 @@ void checkMap(
static_cast<unoidl::EnumTypeEntity *>(entA.get()));
rtl::Reference<unoidl::EnumTypeEntity> ent2B(
static_cast<unoidl::EnumTypeEntity *>(entB.get()));
if (ent2A->getMembers().size()
!= ent2B->getMembers().size())
if (ent2A->getMembers().size() != ent2B->getMembers().size())
{
std::cerr
<< "enum type " << name
<< " number of members changed from "
<< ent2A->getMembers().size() << " to "
<< ent2B->getMembers().size() << std::endl;
<< ent2B->getMembers().size()
<< std::endl;
std::exit(EXIT_FAILURE);
}
for (std::vector<unoidl::EnumTypeEntity::Member>::const_iterator
......@@ -216,13 +238,16 @@ void checkMap(
j(ent2B->getMembers().begin());
i != ent2A->getMembers().end(); ++i, ++j)
{
if (i->name != j->name || i->value != j->value) {
if (i->name != j->name ||
i->value != j->value)
{
std::cerr
<< "enum type " << name << " member #"
<< i - ent2A->getMembers().begin() + 1
<< " changed from " << i->name << " = "
<< i->value << " to " << j->name << " = "
<< j->value << std::endl;
<< j->value
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
......@@ -231,20 +256,18 @@ void checkMap(
case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
{
rtl::Reference<unoidl::PlainStructTypeEntity> ent2A(
static_cast<unoidl::PlainStructTypeEntity *>(
entA.get()));
static_cast<unoidl::PlainStructTypeEntity *>(entA.get()));
rtl::Reference<unoidl::PlainStructTypeEntity> ent2B(
static_cast<unoidl::PlainStructTypeEntity *>(
entB.get()));
if (ent2A->getDirectBase() != ent2B->getDirectBase()) {
static_cast<unoidl::PlainStructTypeEntity *>(entB.get()));
if (ent2A->getDirectBase() != ent2B->getDirectBase())
{
std::cerr
<< "plain struct type " << name
<< " direct base changed from "
<< (ent2A->getDirectBase().isEmpty()
? OUString("none") : ent2A->getDirectBase())
<< (ent2A->getDirectBase().isEmpty() ? OUString("none") : ent2A->getDirectBase())
<< " to "
<< (ent2B->getDirectBase().isEmpty()
? OUString("none") : ent2B->getDirectBase())
<< (ent2B->getDirectBase().isEmpty() ? OUString("none") : ent2B->getDirectBase())
<< std::endl;
std::exit(EXIT_FAILURE);
}
......@@ -263,7 +286,9 @@ void checkMap(
j(ent2B->getDirectMembers().begin());
i != ent2A->getDirectMembers().end(); ++i, ++j)
{
if (i->name != j->name || i->type != j->type) {
if (i->name != j->name ||
i->type != j->type)
{
std::cerr
<< "plain struct type " << name
<< " direct member #"
......@@ -279,21 +304,18 @@ void checkMap(
case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
{
rtl::Reference<unoidl::PolymorphicStructTypeTemplateEntity>
ent2A(
static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>(
entA.get()));
ent2A(static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>(entA.get()));
rtl::Reference<unoidl::PolymorphicStructTypeTemplateEntity>
ent2B(
static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>(
entB.get()));
if (ent2A->getTypeParameters().size()
!= ent2B->getTypeParameters().size())
ent2B(static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>(entB.get()));
if (ent2A->getTypeParameters().size() != ent2B->getTypeParameters().size())
{
std::cerr
<< "polymorphic struct type template " << name
<< " number of type parameters changed from "
<< ent2A->getTypeParameters().size() << " to "
<< ent2B->getTypeParameters().size() << std::endl;
<< ent2B->getTypeParameters().size()
<< std::endl;
std::exit(EXIT_FAILURE);
}
for (std::vector<OUString>::const_iterator
......@@ -301,7 +323,8 @@ void checkMap(
j(ent2B->getTypeParameters().begin());
i != ent2A->getTypeParameters().end(); ++i, ++j)
{
if (*i != *j) {
if (*i != *j)
{
std::cerr
<< "polymorphic struct type template " << name
<< " type parameter #"
......@@ -311,8 +334,7 @@ void checkMap(
std::exit(EXIT_FAILURE);
}
}
if (ent2A->getMembers().size()
!= ent2B->getMembers().size())
if (ent2A->getMembers().size() != ent2B->getMembers().size())
{
std::cerr
<< "polymorphic struct type template " << name
......@@ -326,20 +348,19 @@ void checkMap(
j(ent2B->getMembers().begin());
i != ent2A->getMembers().end(); ++i, ++j)
{
if (i->name != j->name || i->type != j->type
|| i->parameterized != j->parameterized)
if (i->name != j->name ||
i->type != j->type ||
i->parameterized != j->parameterized)
{
std::cerr
<< "polymorphic struct type template " << name
<< " member #"
<< i - ent2A->getMembers().begin() + 1
<< " changed from "
<< (i->parameterized
? OUString("parameterized ") : OUString())
<< (i->parameterized ? OUString("parameterized ") : OUString())
<< i->type << " " << i->name
<< " to "
<< (j->parameterized
? OUString("parameterized ") : OUString())
<< (j->parameterized ? OUString("parameterized ") : OUString())
<< j->type << " " << j->name
<< std::endl;
std::exit(EXIT_FAILURE);
......@@ -353,20 +374,18 @@ void checkMap(
static_cast<unoidl::ExceptionTypeEntity *>(entA.get()));
rtl::Reference<unoidl::ExceptionTypeEntity> ent2B(
static_cast<unoidl::ExceptionTypeEntity *>(entB.get()));
if (ent2A->getDirectBase() != ent2B->getDirectBase()) {
if (ent2A->getDirectBase() != ent2B->getDirectBase())
{
std::cerr
<< "exception type " << name
<< " direct base changed from "
<< (ent2A->getDirectBase().isEmpty()
? OUString("none") : ent2A->getDirectBase())
<< (ent2A->getDirectBase().isEmpty() ? OUString("none") : ent2A->getDirectBase())
<< " to "
<< (ent2B->getDirectBase().isEmpty()
? OUString("none") : ent2B->getDirectBase())
<< (ent2B->getDirectBase().isEmpty() ? OUString("none") : ent2B->getDirectBase())
<< std::endl;
std::exit(EXIT_FAILURE);
}
if (ent2A->getDirectMembers().size()
!= ent2B->getDirectMembers().size())
if (ent2A->getDirectMembers().size() != ent2B->getDirectMembers().size())
{
std::cerr
<< "exception type " << name
......@@ -380,7 +399,8 @@ void checkMap(
j(ent2B->getDirectMembers().begin());
i != ent2A->getDirectMembers().end(); ++i, ++j)
{
if (i->name != j->name || i->type != j->type) {
if (i->name != j->name || i->type != j->type)
{
std::cerr
<< "exception type " << name
<< " direct member #"
......@@ -399,8 +419,7 @@ void checkMap(
static_cast<unoidl::InterfaceTypeEntity *>(entA.get()));
rtl::Reference<unoidl::InterfaceTypeEntity> ent2B(
static_cast<unoidl::InterfaceTypeEntity *>(entB.get()));
if (ent2A->getDirectMandatoryBases().size()
!= ent2B->getDirectMandatoryBases().size())
if (ent2A->getDirectMandatoryBases().size() != ent2B->getDirectMandatoryBases().size())
{
std::cerr
<< "interface type " << name
......@@ -415,19 +434,20 @@ void checkMap(
j(ent2B->getDirectMandatoryBases().begin());
i != ent2A->getDirectMandatoryBases().end(); ++i, ++j)
{
if (i->name != j->name) {
if (i->name != j->name)
{
std::cerr
<< "interface type " << name
<< " direct mandatory base #"
<< (i - ent2A->getDirectMandatoryBases().begin()
+ 1)
<< " changed from " << i->name << " to "
<< j->name << std::endl;
<< j->name
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
if (ent2A->getDirectOptionalBases().size()
!= ent2B->getDirectOptionalBases().size())
if (ent2A->getDirectOptionalBases().size() != ent2B->getDirectOptionalBases().size())
{
std::cerr
<< "interface type " << name
......@@ -442,14 +462,15 @@ void checkMap(
j(ent2B->getDirectOptionalBases().begin());
i != ent2A->getDirectOptionalBases().end(); ++i, ++j)
{
if (i->name != j->name) {
if (i->name != j->name)
{
std::cerr
<< "interface type " << name
<< " direct optional base #"
<< (i - ent2A->getDirectOptionalBases().begin()
+ 1)
<< (i - ent2A->getDirectOptionalBases().begin() + 1)
<< " changed from " << i->name << " to "
<< j->name << std::endl;
<< j->name
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
......@@ -468,11 +489,12 @@ void checkMap(
j(ent2B->getDirectAttributes().begin());
i != ent2A->getDirectAttributes().end(); ++i, ++j)
{
if (i->name != j->name || i->type != j->type
|| i->bound != j->bound
|| i->readOnly != j->readOnly
|| i->getExceptions != j->getExceptions
|| i->setExceptions != j->setExceptions)
if (i->name != j->name ||
i->type != j->type ||
i->bound != j->bound ||
i->readOnly != j->readOnly ||
i->getExceptions != j->getExceptions ||
i->setExceptions != j->setExceptions)
{
std::cerr
<< "interface type " << name
......@@ -480,13 +502,11 @@ void checkMap(
<< i - ent2A->getDirectAttributes().begin() + 1
<< " changed from "
<< (i->bound ? OUString("bound ") : OUString())
<< (i->readOnly
? OUString("read-only ") : OUString())
<< (i->readOnly ? OUString("read-only ") : OUString())
<< i->type << " " << i->name //TODO: exceptions
<< " to "
<< (j->bound ? OUString("bound ") : OUString())
<< (j->readOnly
? OUString("read-only ") : OUString())
<< (j->readOnly ? OUString("read-only ") : OUString())
<< j->type << " " << j->name //TODO: exceptions
<< std::endl;
std::exit(EXIT_FAILURE);
......@@ -507,8 +527,9 @@ void checkMap(
j(ent2B->getDirectMethods().begin());
i != ent2A->getDirectMethods().end(); ++i, ++j)
{
if (i->name != j->name || i->returnType != j->returnType
|| i->exceptions != j->exceptions)
if (i->name != j->name ||
i->returnType != j->returnType ||
i->exceptions != j->exceptions)
{
std::cerr
<< "interface type " << name
......@@ -520,13 +541,15 @@ void checkMap(
<< std::endl;
std::exit(EXIT_FAILURE);
}
if (i->parameters.size() != j->parameters.size()) {
if (i->parameters.size() != j->parameters.size())
{
std::cerr
<< "interface type " << name
<< " direct method " << i->name
<< " number of parameters changed from "
<< i->parameters.size() << " to "
<< j->parameters.size() << std::endl;
<< j->parameters.size()
<< std::endl;
std::exit(EXIT_FAILURE);
}
for (std::vector<unoidl::InterfaceTypeEntity::Method::Parameter>::const_iterator
......@@ -545,17 +568,20 @@ void checkMap(
<< showDirection(k->direction) << " "
<< k->type << " to "
<< showDirection(l->direction) << " "
<< l->type << std::endl;
<< l->type
<< std::endl;
std::exit(EXIT_FAILURE);
}
if (k->name != l->name) {
if (k->name != l->name)
{
std::cerr
<< "interface type " << name
<< " direct method " << i->name
<< " parameter #"
<< k - i->parameters.begin() + 1
<< " changed name from " << k->name
<< " to " << l->name << std::endl;
<< " to " << l->name
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
......@@ -568,7 +594,8 @@ void checkMap(
static_cast<unoidl::TypedefEntity *>(entA.get()));
rtl::Reference<unoidl::TypedefEntity> ent2B(
static_cast<unoidl::TypedefEntity *>(entB.get()));
if (ent2A->getType() != ent2B->getType()) {
if (ent2A->getType() != ent2B->getType())
{
std::cerr
<< "typedef " << name << " type changed from "
<< ent2A->getType() << " to " << ent2B->getType()
......@@ -592,19 +619,23 @@ void checkMap(
j(ent2B->getMembers().begin());
j != ent2B->getMembers().end(); ++j)
{
if (i->name == j->name) {
if (i->value != j->value) {
if (i->name == j->name)
{
if (i->value != j->value)
{
std::cerr
<< "constant group " << name
<< " member " << i->name
<< " changed value" << std::endl;
<< " changed value"
<< std::endl;
std::exit(EXIT_FAILURE);
}
found = true;
break;
}
}
if (!found) {
if (!found)
{
std::cerr
<< "A constant group " << name << " member "
<< i->name << " is not present in B"
......@@ -617,14 +648,11 @@ void checkMap(
case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
{
rtl::Reference<unoidl::SingleInterfaceBasedServiceEntity>
ent2A(
static_cast<unoidl::SingleInterfaceBasedServiceEntity *>(
entA.get()));
ent2A( static_cast<unoidl::SingleInterfaceBasedServiceEntity *>( entA.get()));
rtl::Reference<unoidl::SingleInterfaceBasedServiceEntity>
ent2B(
static_cast<unoidl::SingleInterfaceBasedServiceEntity *>(
entB.get()));
if (ent2A->getBase() != ent2B->getBase()) {
ent2B( static_cast<unoidl::SingleInterfaceBasedServiceEntity *>( entB.get()));
if (ent2A->getBase() != ent2B->getBase())
{
std::cerr
<< "single-interface--based servcie " << name
<< " base changed from " << ent2A->getBase()
......@@ -632,8 +660,7 @@ void checkMap(
<< std::endl;
std::exit(EXIT_FAILURE);
}
if (ent2A->getConstructors().size()
!= ent2B->getConstructors().size())
if (ent2A->getConstructors().size() != ent2B->getConstructors().size())
{
std::cerr
<< "single-interface--based service " << name
......@@ -647,20 +674,19 @@ void checkMap(
j(ent2B->getConstructors().begin());
i != ent2A->getConstructors().end(); ++i, ++j)
{
if (i->name != j->name || i->parameters != j->parameters
|| i->exceptions != j->exceptions
|| i->defaultConstructor != j->defaultConstructor)
if (i->name != j->name ||
i->parameters != j->parameters ||
i->exceptions != j->exceptions ||
i->defaultConstructor != j->defaultConstructor)
{
std::cerr
<< "single-interface--based service " << name
<< " constructor #"
<< i - ent2A->getConstructors().begin() + 1
<< " changed from "
<< (i->defaultConstructor
? OUString("default ") : i->name) //TODO: parameters, exceptions
<< (i->defaultConstructor ? OUString("default ") : i->name) //TODO: parameters, exceptions
<< " to "
<< (j->defaultConstructor
? OUString("default ") : j->name) //TODO: parameters, exceptions
<< (j->defaultConstructor ? OUString("default ") : j->name) //TODO: parameters, exceptions
<< std::endl;
std::exit(EXIT_FAILURE);
}
......@@ -670,20 +696,15 @@ void checkMap(
case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE:
{
rtl::Reference<unoidl::AccumulationBasedServiceEntity>
ent2A(
static_cast<unoidl::AccumulationBasedServiceEntity *>(
entA.get()));
ent2A( static_cast<unoidl::AccumulationBasedServiceEntity *>( entA.get()));
rtl::Reference<unoidl::AccumulationBasedServiceEntity>
ent2B(
static_cast<unoidl::AccumulationBasedServiceEntity *>(
entB.get()));
if (ent2A->getDirectMandatoryBaseServices().size()
!= ent2B->getDirectMandatoryBaseServices().size())
ent2B( static_cast<unoidl::AccumulationBasedServiceEntity *>( entB.get()));
if (ent2A->getDirectMandatoryBaseServices().size() != ent2B->getDirectMandatoryBaseServices().size())
{
std::cerr
<< "accumulation-based service " << name
<< (" number of direct mandatory base services"
" changed from ")
<< " number of direct mandatory base services changed from "
<< ent2A->getDirectMandatoryBaseServices().size()
<< " to "
<< ent2B->getDirectMandatoryBaseServices().size()
......@@ -696,26 +717,22 @@ void checkMap(
i != ent2A->getDirectMandatoryBaseServices().end();
++i, ++j)
{
if (i->name != j->name) {
if (i->name != j->name)
{
std::cerr
<< "accumulation-based service " << name
<< " direct mandatory base service #"
<< (i
- (ent2A->getDirectMandatoryBaseServices()
.begin())
+ 1)
<< (i - (ent2A->getDirectMandatoryBaseServices().begin()) + 1)
<< " changed from " << i->name << " to "
<< j->name << std::endl;
std::exit(EXIT_FAILURE);
}
}
if (ent2A->getDirectOptionalBaseServices().size()
> ent2B->getDirectOptionalBaseServices().size())
if (ent2A->getDirectOptionalBaseServices().size() > ent2B->getDirectOptionalBaseServices().size())
{
std::cerr
<< "accumulation-based service " << name
<< (" number of direct optional base services"
" shrank from ")
<< " number of direct optional base services shrank from "
<< ent2A->getDirectOptionalBaseServices().size()
<< " to "
<< ent2B->getDirectOptionalBaseServices().size()
......@@ -754,28 +771,23 @@ void checkMap(
std::exit(EXIT_FAILURE);
}
for (std::vector<unoidl::AnnotatedReference>::const_iterator
i(ent2A->getDirectMandatoryBaseInterfaces()
.begin()),
j(ent2B->getDirectMandatoryBaseInterfaces()
.begin());
i(ent2A->getDirectMandatoryBaseInterfaces().begin()),
j(ent2B->getDirectMandatoryBaseInterfaces().begin());
i != ent2A->getDirectMandatoryBaseInterfaces().end();
++i, ++j)
{
if (i->name != j->name) {
if (i->name != j->name)
{
std::cerr
<< "accumulation-based service " << name
<< " direct mandatory base interface #"
<< (i
- (ent2A->getDirectMandatoryBaseInterfaces()
.begin())
+ 1)
<< (i - (ent2A->getDirectMandatoryBaseInterfaces().begin()) + 1)
<< " changed from " << i->name << " to "
<< j->name << std::endl;
std::exit(EXIT_FAILURE);
}
}
if (ent2A->getDirectOptionalBaseInterfaces().size()
> ent2B->getDirectOptionalBaseInterfaces().size())
if (ent2A->getDirectOptionalBaseInterfaces().size() > ent2B->getDirectOptionalBaseInterfaces().size())
{
std::cerr
<< "accumulation-based service " << name
......@@ -788,14 +800,12 @@ void checkMap(
std::exit(EXIT_FAILURE);
}
for (std::vector<unoidl::AnnotatedReference>::const_iterator
i(ent2A->getDirectOptionalBaseInterfaces()
.begin());
i(ent2A->getDirectOptionalBaseInterfaces().begin());
i != ent2A->getDirectOptionalBaseInterfaces().end();
++i)
{
if (std::find_if(
(ent2B->getDirectOptionalBaseInterfaces()
.begin()),
(ent2B->getDirectOptionalBaseInterfaces().begin()),
ent2B->getDirectOptionalBaseInterfaces().end(),
EqualsAnnotation(i->name))
== ent2B->getDirectOptionalBaseInterfaces().end())
......@@ -807,8 +817,7 @@ void checkMap(
std::exit(EXIT_FAILURE);
}
}
if (ent2A->getDirectProperties().size()
> ent2B->getDirectProperties().size())
if (ent2A->getDirectProperties().size() > ent2B->getDirectProperties().size())
{
std::cerr
<< "accumulation-based service " << name
......@@ -822,8 +831,9 @@ void checkMap(
j(ent2B->getDirectProperties().begin());
i != ent2A->getDirectProperties().end(); ++i, ++j)
{
if (i->name != j->name || i->type != j->type
|| i->attributes != j->attributes)
if (i->name != j->name ||
i->type != j->type ||
i->attributes != j->attributes)
{
std::cerr
<< "accumulation-based service " << name
......@@ -856,12 +866,12 @@ void checkMap(
case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON:
{
rtl::Reference<unoidl::InterfaceBasedSingletonEntity> ent2A(
static_cast<unoidl::InterfaceBasedSingletonEntity *>(
entA.get()));
static_cast<unoidl::InterfaceBasedSingletonEntity *>(entA.get()));
rtl::Reference<unoidl::InterfaceBasedSingletonEntity> ent2B(
static_cast<unoidl::InterfaceBasedSingletonEntity *>(
entB.get()));
if (ent2A->getBase() != ent2B->getBase()) {
static_cast<unoidl::InterfaceBasedSingletonEntity *>(entB.get()));
if (ent2A->getBase() != ent2B->getBase())
{
std::cerr
<< "interface-based singleton " << name
<< " base changed from " << ent2A->getBase()
......@@ -873,16 +883,17 @@ void checkMap(
case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON:
{
rtl::Reference<unoidl::ServiceBasedSingletonEntity> ent2A(
static_cast<unoidl::ServiceBasedSingletonEntity *>(
entA.get()));
static_cast<unoidl::ServiceBasedSingletonEntity *>(entA.get()));
rtl::Reference<unoidl::ServiceBasedSingletonEntity> ent2B(
static_cast<unoidl::ServiceBasedSingletonEntity *>(
entB.get()));
if (ent2A->getBase() != ent2B->getBase()) {
static_cast<unoidl::ServiceBasedSingletonEntity *>(entB.get()));
if (ent2A->getBase() != ent2B->getBase())
{
std::cerr
<< "service-based singleton " << name
<< " base changed from " << ent2A->getBase()
<< " to " << ent2B->getBase() << std::endl;
<< " to " << ent2B->getBase()
<< std::endl;
std::exit(EXIT_FAILURE);
}
break;
......@@ -892,71 +903,81 @@ void checkMap(
}
}
bool valid(OUString const & identifier) {
for (sal_Int32 i = 0;; ++i) {
bool valid(OUString const & identifier)
{
for (sal_Int32 i = 0;; ++i)
{
i = identifier.indexOf('_', i);
if (i == -1) {
if (i == -1)
{
return true;
}
if (!rtl::isAsciiUpperCase(identifier[0]) || identifier[i - 1] == '_') {
if (!rtl::isAsciiUpperCase(identifier[0]) || identifier[i - 1] == '_')
{
return false;
}
}
}
void checkIds(
rtl::Reference<unoidl::Provider> const & providerA, OUString const & prefix,
void checkIds( rtl::Reference<unoidl::Provider> const & providerA, OUString const & prefix,
rtl::Reference<unoidl::MapCursor> const & cursor)
{
assert(cursor.is());
for (;;) {
for (;;)
{
OUString id;
rtl::Reference<unoidl::Entity> entB(cursor->getNext(&id));
if (!entB.is()) {
if (!entB.is())
{
break;
}
OUString name(prefix + id);
rtl::Reference<unoidl::Entity> entA(providerA->findEntity(name));
if (!(entA.is() || valid(id))) {
if (!(entA.is() || valid(id)))
{
std::cerr
<< "entity name " << name << " uses an invalid identifier"
<< std::endl;
std::exit(EXIT_FAILURE);
}
switch (entB->getSort()) {
switch (entB->getSort())
{
case unoidl::Entity::SORT_MODULE:
checkIds(
providerA, name + ".",
(static_cast<unoidl::ModuleEntity *>(entB.get())
->createCursor()));
checkIds( providerA, name + ".",
(static_cast<unoidl::ModuleEntity *>(entB.get())->createCursor()));
break;
case unoidl::Entity::SORT_ENUM_TYPE:
if (!entA.is()) {
rtl::Reference<unoidl::EnumTypeEntity> ent2B(
static_cast<unoidl::EnumTypeEntity *>(entB.get()));
if (!entA.is())
{
rtl::Reference<unoidl::EnumTypeEntity> ent2B(static_cast<unoidl::EnumTypeEntity *>(entB.get()));
for (std::vector<unoidl::EnumTypeEntity::Member>::const_iterator
i(ent2B->getMembers().begin());
i != ent2B->getMembers().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "enum type " << name << " member " << i->name
<< " uses an invalid identifier" << std::endl;
<< " uses an invalid identifier"
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
}
break;
case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE:
if (!entA.is()) {
if (!entA.is())
{
rtl::Reference<unoidl::PlainStructTypeEntity> ent2B(
static_cast<unoidl::PlainStructTypeEntity *>(
entB.get()));
static_cast<unoidl::PlainStructTypeEntity *>(entB.get()));
for (std::vector<unoidl::PlainStructTypeEntity::Member>::const_iterator
i(ent2B->getDirectMembers().begin());
i != ent2B->getDirectMembers().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "plain struct type " << name << " direct member "
<< i->name << " uses an invalid identifier"
......@@ -967,21 +988,21 @@ void checkIds(
}
break;
case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE:
if (!entA.is()) {
if (!entA.is())
{
rtl::Reference<unoidl::PolymorphicStructTypeTemplateEntity>
ent2B(
static_cast<
unoidl::PolymorphicStructTypeTemplateEntity *>(
entB.get()));
for (std::vector<OUString>::const_iterator i(
ent2B->getTypeParameters().begin());
ent2B( static_cast< unoidl::PolymorphicStructTypeTemplateEntity *>(entB.get()));
for (std::vector<OUString>::const_iterator i(ent2B->getTypeParameters().begin());
i != ent2B->getTypeParameters().end(); ++i)
{
if (!valid(*i)) {
if (!valid(*i))
{
std::cerr
<< "polymorphic struct type template " << name
<< " type parameter " << *i
<< " uses an invalid identifier" << std::endl;
<< " uses an invalid identifier"
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
......@@ -989,7 +1010,8 @@ void checkIds(
i(ent2B->getMembers().begin());
i != ent2B->getMembers().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "polymorphic struct type template " << name
<< " member " << i->name
......@@ -1000,14 +1022,17 @@ void checkIds(
}
break;
case unoidl::Entity::SORT_EXCEPTION_TYPE:
if (!entA.is()) {
if (!entA.is())
{
rtl::Reference<unoidl::ExceptionTypeEntity> ent2B(
static_cast<unoidl::ExceptionTypeEntity *>(entB.get()));
for (std::vector<unoidl::ExceptionTypeEntity::Member>::const_iterator
i(ent2B->getDirectMembers().begin());
i != ent2B->getDirectMembers().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "exception type " << name << " direct member "
<< i->name << " uses an invalid identifier"
......@@ -1018,14 +1043,16 @@ void checkIds(
}
break;
case unoidl::Entity::SORT_INTERFACE_TYPE:
if (!entA.is()) {
if (!entA.is())
{
rtl::Reference<unoidl::InterfaceTypeEntity> ent2B(
static_cast<unoidl::InterfaceTypeEntity *>(entB.get()));
for (std::vector<unoidl::InterfaceTypeEntity::Attribute>::const_iterator
i(ent2B->getDirectAttributes().begin());
i != ent2B->getDirectAttributes().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "interface type " << name << " direct attribute "
<< i->name << " uses an invalid identifier"
......@@ -1037,7 +1064,8 @@ void checkIds(
i(ent2B->getDirectMethods().begin());
i != ent2B->getDirectMethods().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "interface type " << name << " direct method "
<< i->name << " uses an invalid identifier"
......@@ -1048,7 +1076,8 @@ void checkIds(
j(i->parameters.begin());
j != i->parameters.end(); ++j)
{
if (!valid(j->name)) {
if (!valid(j->name))
{
std::cerr
<< "interface type " << name
<< " direct method " << i->name << " parameter "
......@@ -1073,7 +1102,8 @@ void checkIds(
i != ent2B->getMembers().end(); ++i)
{
bool found = false;
if (entA.is()) {
if (entA.is())
{
rtl::Reference<unoidl::ConstantGroupEntity> ent2A(
static_cast<unoidl::ConstantGroupEntity *>(
entA.get()));
......@@ -1081,13 +1111,15 @@ void checkIds(
j(ent2A->getMembers().begin());
j != ent2A->getMembers().end(); ++j)
{
if (i->name == j->name) {
if (i->name == j->name)
{
found = true;
break;
}
}
}
if (!(found || valid(i->name))) {
if (!(found || valid(i->name)))
{
std::cerr
<< "Constant group " << name << " member "
<< i->name << " uses an invalid identifier"
......@@ -1098,27 +1130,31 @@ void checkIds(
break;
}
case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE:
if (!entA.is()) {
if (!entA.is())
{
rtl::Reference<unoidl::SingleInterfaceBasedServiceEntity>
ent2B(
static_cast<unoidl::SingleInterfaceBasedServiceEntity *>(
ent2B( static_cast<unoidl::SingleInterfaceBasedServiceEntity *>(
entB.get()));
for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor>::const_iterator
i(ent2B->getConstructors().begin());
i != ent2B->getConstructors().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "single-interface--based service " << name
<< " constructor " << i->name
<< " uses an invalid identifier" << std::endl;
<< " uses an invalid identifier"
<< std::endl;
std::exit(EXIT_FAILURE);
}
for (std::vector<unoidl::SingleInterfaceBasedServiceEntity::Constructor::Parameter>::const_iterator
j(i->parameters.begin());
j != i->parameters.end(); ++j)
{
if (!valid(j->name)) {
if (!valid(j->name))
{
std::cerr
<< "single-interface--based service " << name
<< " constructor " << i->name << " parameter "
......@@ -1136,21 +1172,21 @@ void checkIds(
static_cast<unoidl::AccumulationBasedServiceEntity *>(
entB.get()));
std::vector<unoidl::AccumulationBasedServiceEntity::Property>::size_type
n(entA.is()
? (static_cast<unoidl::AccumulationBasedServiceEntity *>(
entA.get())
->getDirectProperties().size())
: 0);
n(entA.is() ?
(static_cast<unoidl::AccumulationBasedServiceEntity *>(entA.get())->getDirectProperties().size()) : 0);
assert(n <= ent2B->getDirectProperties().size());
for (std::vector<unoidl::AccumulationBasedServiceEntity::Property>::const_iterator
i(ent2B->getDirectProperties().begin() + n);
i != ent2B->getDirectProperties().end(); ++i)
{
if (!valid(i->name)) {
if (!valid(i->name))
{
std::cerr
<< "accumulation-based service " << name
<< " direct property " << i->name
<< " uses an invalid identifier" << std::endl;
<< " uses an invalid identifier"
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
......@@ -1162,36 +1198,50 @@ void checkIds(
}
SAL_IMPLEMENT_MAIN() {
try {
SAL_IMPLEMENT_MAIN()
{
try
{
sal_uInt32 args = rtl_getAppCommandArgCount();
rtl::Reference<unoidl::Manager> mgr[2];
mgr[0] = new unoidl::Manager;
mgr[1] = new unoidl::Manager;
rtl::Reference<unoidl::Provider> prov[2];
int side = 0;
for (sal_uInt32 i = 0; i != args; ++i) {
for (sal_uInt32 i = 0; i != args; ++i)
{
bool delimiter = false;
OUString uri(getArgumentUri(i, side == 0 ? &delimiter : 0));
if (delimiter) {
if (delimiter)
{
side = 1;
} else {
try {
}
else
{
try
{
prov[side] = mgr[side]->addProvider(uri);
} catch (unoidl::NoSuchFileException &) {
}
catch (unoidl::NoSuchFileException &)
{
std::cerr
<< "Input <" << uri << "> does not exist" << std::endl;
<< "Input <" << uri << "> does not exist"
<< std::endl;
std::exit(EXIT_FAILURE);
}
}
}
if (side == 0 || !(prov[0].is() && prov[1].is())) {
if (side == 0 || !(prov[0].is() && prov[1].is()))
{
badUsage();
}
checkMap(prov[1], "", prov[0]->createRootCursor());
checkIds(prov[0], "", prov[1]->createRootCursor());
return EXIT_SUCCESS;
} catch (unoidl::FileFormatException & e1) {
}
catch (unoidl::FileFormatException & e1)
{
std::cerr
<< "Bad input <" << e1.getUri() << ">: " << e1.getDetail()
<< std::endl;
......
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