summaryrefslogtreecommitdiff
path: root/unoidl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-09-16 21:53:14 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-09-17 06:55:41 +0200
commit65a1f81a70e4268801a09106df54fcb2497c6d7d (patch)
tree2bede1e9ad2e128c530b8e4d7b87e874a08f0e4f /unoidl
parent04a002491b149bee6ba972e8288f867c791db19e (diff)
Detect reuse of module names for other entities
Change-Id: Ifc8d95b4b15a7dd91195e6f727fdb7fa2a267be9
Diffstat (limited to 'unoidl')
-rw-r--r--unoidl/source/sourceprovider-parser.y35
-rw-r--r--unoidl/source/sourceprovider-scanner.hxx9
2 files changed, 39 insertions, 5 deletions
diff --git a/unoidl/source/sourceprovider-parser.y b/unoidl/source/sourceprovider-parser.y
index 7d5f108fae2f..cc18854b1245 100644
--- a/unoidl/source/sourceprovider-parser.y
+++ b/unoidl/source/sourceprovider-parser.y
@@ -460,6 +460,8 @@ Found findEntity(
case unoidl::detail::SourceProviderEntity::KIND_INTERFACE_DECL:
argT = unoidl::detail::SourceProviderType::TYPE_INTERFACE;
break;
+ case unoidl::detail::SourceProviderEntity::KIND_MODULE:
+ assert(false); // this cannot happen
}
argType
= unoidl::detail::SourceProviderType(
@@ -546,6 +548,11 @@ Found findEntity(
e->entity = ent;
}
break;
+ case unoidl::detail::SourceProviderEntity::KIND_MODULE:
+ error(
+ location, yyscanner,
+ *name + " is based on module entity " + n);
+ return FOUND_ERROR;
}
}
if (!typeNucleus.isEmpty() || rank != 0 || !args.empty()) {
@@ -696,6 +703,8 @@ Found findEntity(
unoidl::detail::SourceProviderType::TYPE_INTERFACE,
n, e);
break;
+ case unoidl::detail::SourceProviderEntity::KIND_MODULE:
+ assert(false); // this cannot happen
}
}
} else {
@@ -757,6 +766,8 @@ Found findEntity(
+ n
+ " that is not a polymorphic struct type template"));
return FOUND_ERROR;
+ case unoidl::detail::SourceProviderEntity::KIND_MODULE:
+ assert(false); // this cannot happen
}
}
if (typedefedType != 0) {
@@ -904,7 +915,21 @@ moduleDecl:
TOK_MODULE identifier
{
unoidl::detail::SourceProviderScannerData * data = yyget_extra(yyscanner);
- data->modules.push_back(convertToFullName(data, $2));
+ OUString name(convertToFullName(data, $2));
+ data->modules.push_back(name);
+ std::pair<std::map<OUString, unoidl::detail::SourceProviderEntity>::iterator, bool> p(
+ data->entities.insert(
+ std::map<OUString, unoidl::detail::SourceProviderEntity>::value_type(
+ name,
+ unoidl::detail::SourceProviderEntity(
+ unoidl::detail::SourceProviderEntity::KIND_MODULE))));
+ if (!p.second
+ && (p.first->second.kind
+ != unoidl::detail::SourceProviderEntity::KIND_MODULE))
+ {
+ error(@2, yyscanner, "multiple entities named " + name);
+ YYERROR;
+ }
}
'{' definitions '}' ';' { yyget_extra(yyscanner)->modules.pop_back(); }
;
@@ -2671,7 +2696,9 @@ interfaceDecl:
std::pair<std::map<OUString, unoidl::detail::SourceProviderEntity>::iterator, bool> p(
data->entities.insert(
std::map<OUString, unoidl::detail::SourceProviderEntity>::value_type(
- name, unoidl::detail::SourceProviderEntity())));
+ name,
+ unoidl::detail::SourceProviderEntity(
+ unoidl::detail::SourceProviderEntity::KIND_INTERFACE_DECL))));
if (!p.second
&& (p.first->second.kind
!= unoidl::detail::SourceProviderEntity::KIND_INTERFACE_DECL))
@@ -3468,6 +3495,8 @@ type:
ent);
ok = true;
break;
+ case unoidl::detail::SourceProviderEntity::KIND_MODULE:
+ assert(false); // this cannot happen
}
if (!ok) {
error(@1, yyscanner, "non-type entity " + name);
@@ -3533,6 +3562,8 @@ type:
break;
case unoidl::detail::SourceProviderEntity::KIND_INTERFACE_DECL:
break;
+ case unoidl::detail::SourceProviderEntity::KIND_MODULE:
+ assert(false); // this cannot happen
}
if (!ok) {
error(@1, yyscanner, "non-type entity " + name);
diff --git a/unoidl/source/sourceprovider-scanner.hxx b/unoidl/source/sourceprovider-scanner.hxx
index 152b9cf6ca2b..51900580e987 100644
--- a/unoidl/source/sourceprovider-scanner.hxx
+++ b/unoidl/source/sourceprovider-scanner.hxx
@@ -189,19 +189,22 @@ private:
};
struct SourceProviderEntity {
- enum Kind { KIND_EXTERNAL, KIND_LOCAL, KIND_INTERFACE_DECL };
+ enum Kind { KIND_EXTERNAL, KIND_LOCAL, KIND_INTERFACE_DECL, KIND_MODULE };
explicit SourceProviderEntity(
Kind theKind, rtl::Reference<unoidl::Entity> const & externalEntity):
kind(theKind), entity(externalEntity)
- { assert(theKind != KIND_INTERFACE_DECL); assert(externalEntity.is()); }
+ { assert(theKind <= KIND_LOCAL); assert(externalEntity.is()); }
explicit SourceProviderEntity(
rtl::Reference<SourceProviderEntityPad> const & localPad):
kind(KIND_LOCAL), pad(localPad)
{ assert(localPad.is()); }
- SourceProviderEntity(): kind(KIND_INTERFACE_DECL) {}
+ explicit SourceProviderEntity(Kind theKind): kind(theKind)
+ { assert(theKind >= KIND_INTERFACE_DECL); }
+
+ SourceProviderEntity() {} // needed for std::map::operator []
Kind kind;
rtl::Reference<unoidl::Entity> entity;