codegen: prevent alternative references
@@ -370,6 +370,13 @@ static void processStructRef (const kdb::Key & key, const kdb::Key & parentKey,
}
auto restrict = key.getMeta<std::string> ("check/reference/restrict");
+
+ if (ckdb::elektraArrayValidateBaseNameString (restrict.c_str ()))
+ {
+ throw CommandAbortException ("Alternative references currently not supported. Key: " + key.getName ());
+ }
+ else
+ {
char * rawResolved = ckdb::elektraResolveReference (restrict.c_str (), key.getKey (), parentKey.getKey ());
auto restrictKey = allKeys.lookup (rawResolved);
@@ -377,12 +384,14 @@ static void processStructRef (const kdb::Key & key, const kdb::Key & parentKey,
if (!restrictKey)
{
- throw CommandAbortException ("'check/reference/restrict' of key '" + key.getName () + "' resolves to an unspecified key.");
+ throw CommandAbortException ("'check/reference/restrict' of key '" + key.getName () +
+ "' resolves to an unspecified key.");
}
if (restrictKey.getMeta<std::string> ("type") != "struct")
{
- throw CommandAbortException ("'check/reference/restrict' of key '" + key.getName () + "' resolves to a non-struct key.");
+ throw CommandAbortException ("'check/reference/restrict' of key '" + key.getName () +
+ "' resolves to a non-struct key.");
}
bool genType;
@@ -391,6 +400,7 @@ static void processStructRef (const kdb::Key & key, const kdb::Key & parentKey,
nativeType = genType ? structType : "Elektra" + typeName;
alloc = StructProcessor::shouldAllocate (restrictKey);
}
+}
static std::vector<std::string> getKeyParts (const kdb::Key & key)
{
