Skip to content

Commit

Permalink
Scripting|libcore: Inheriting from sibling blocks
Browse files Browse the repository at this point in the history
If the provided inherited record is not found in the current namespace,
as a last resort, try the sibling records. Allows more conveniently
inheriting from records that are likely closely related.
  • Loading branch information
skyjake committed Aug 9, 2015
1 parent 36ef720 commit a41089a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doomsday/sdk/libcore/src/scriptsys/scriptedinfo.cpp
Expand Up @@ -128,12 +128,19 @@ DENG2_PIMPL(ScriptedInfo)
if(!varName.isEmpty())
{
Record &ns = process.globals();
// Try a case-sensitive match in global namespace.
String targetName = checkNamespaceForVariable(target);
if(!ns.has(targetName))
{
// Assume it's an identifier rather than a regular variable.
targetName = checkNamespaceForVariable(target.text.toLower());
}
if(!ns.has(targetName))
{
// Try a regular variable within the same block.
targetName = variableName(block.parent()? *block.parent() : block)
.concatenateMember(target);
}

ns.add(varName.concatenateMember("__inherit__")) =
new TextValue(targetName);
Expand Down

0 comments on commit a41089a

Please sign in to comment.