Skip to content

Commit

Permalink
libdeng2|Script|Widgets: Use monospace for 'print' output
Browse files Browse the repository at this point in the history
Also added a RuleRectangle method for copying another rectangle's
input rules, although this should be used in special circumstances
only.
  • Loading branch information
skyjake committed Sep 10, 2013
1 parent cc64511 commit 3351ba2
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
9 changes: 9 additions & 0 deletions doomsday/libdeng2/include/de/scriptsys/script.h
Expand Up @@ -67,6 +67,15 @@ class DENG2_PUBLIC Script

virtual ~Script();

/**
* Parses a source into statements, replacing any statements currently
* in the Script. The user must ensure that the script is not currently
* being executed by a Process.
*
* @param source Script source.
*/
void parse(String const &source);

/**
* Sets the path of the source. Used as the value of __file__ in the
* executing process's global namespace.
Expand Down
18 changes: 17 additions & 1 deletion doomsday/libdeng2/include/de/widgets/rulerectangle.h
Expand Up @@ -64,10 +64,26 @@ class DENG2_PUBLIC RuleRectangle
RuleRectangle &setInput(Rule::Semantic inputRule, Rule const &rule);

RuleRectangle &setLeftTop(Rule const &left, Rule const &top);

RuleRectangle &setRightBottom(Rule const &right, Rule const &bottom);
RuleRectangle &setRect(RuleRectangle const &rect);

RuleRectangle &setSize(Rule const &width, Rule const &height);

/**
* Sets the outputs of another rule rectangle as the inputs of this one.
*
* @param rect Rectangle whose outputs to use as inputs.
*/
RuleRectangle &setRect(RuleRectangle const &rect);

/**
* Sets the inputs of another rule rectangle as the inputs of this one.
* (Note the difference to setRect().)
*
* @param rect Rectangle whose inputs to use as inputs.
*/
RuleRectangle &setInputsFromRect(RuleRectangle const &rect);

RuleRectangle &clearInput(Rule::Semantic inputRule);

/**
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/scriptsys/parser.cpp
Expand Up @@ -861,8 +861,8 @@ Expression *Parser::parseTokenExpression(TokenRange const &range, Expression::Fl

default:
throw UnexpectedTokenError("Parser::parseTokenExpression",
token.asText() + " which was identified as " +
Token::typeToText(token.type()) + " was unexpected");
"Unexpected " + token.asText() + " which was identified as " +
Token::typeToText(token.type()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/scriptsys/printstatement.cpp
Expand Up @@ -63,7 +63,7 @@ void PrintStatement::execute(Context &context) const
os << (*i)->asText();
}

LOG_MSG("") << msg;
LOG_MSG(_E(m)) << msg;

context.proceed();
}
Expand Down
6 changes: 6 additions & 0 deletions doomsday/libdeng2/src/scriptsys/script.cpp
Expand Up @@ -39,6 +39,12 @@ Script::Script(File const &file) : _path(file.path())
Script::~Script()
{}

void Script::parse(String const &source)
{
_compound.clear();
Parser().parse(source, *this);
}

Statement const *Script::firstStatement() const
{
return _compound.firstStatement();
Expand Down
17 changes: 17 additions & 0 deletions doomsday/libdeng2/src/widgets/rulerectangle.cpp
Expand Up @@ -270,6 +270,22 @@ RuleRectangle &RuleRectangle::setRect(RuleRectangle const &rect)
return *this;
}

RuleRectangle &RuleRectangle::setInputsFromRect(RuleRectangle const &rect)
{
for(int i = 0; i < int(Rule::MAX_SEMANTICS); ++i)
{
if(rect.d->inputRules[i])
{
setInput(Rule::Semantic(i), *rect.d->inputRules[i]);
}
else
{
clearInput(Rule::Semantic(i));
}
}
return *this;
}

RuleRectangle &RuleRectangle::setSize(Rule const &width, Rule const &height)
{
setInput(Rule::Width, width);
Expand All @@ -285,6 +301,7 @@ RuleRectangle &RuleRectangle::clearInput(Rule::Semantic inputRule)

Rule const &RuleRectangle::inputRule(Rule::Semantic inputRule)
{
DENG2_ASSERT(d->ruleRef(inputRule) != 0);
return *d->ruleRef(inputRule);
}

Expand Down

0 comments on commit 3351ba2

Please sign in to comment.