Skip to content

Commit

Permalink
ACTIONSCRIPT: Convert numbers to strings on calling asString()
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Feb 23, 2019
1 parent 42d1710 commit 301d7e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/aurora/actionscript/variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* A variable used in the execution context.
*/

#include "src/common/strutil.h"

#include "src/aurora/actionscript/variable.h"
#include "src/aurora/actionscript/object.h"
#include "src/aurora/actionscript/function.h"
Expand Down Expand Up @@ -134,8 +136,15 @@ ObjectPtr Variable::asObject() {
return _value.object;
}

const Common::UString &Variable::asString() const {
return _value.string;
const Common::UString Variable::asString() const {
switch (_type) {
case kTypeNumber:
return Common::composeString(_value.number);
case kTypeString:
return _value.string;
default:
return "";
}
}

bool Variable::asBoolean() const {
Expand Down
2 changes: 1 addition & 1 deletion src/aurora/actionscript/variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Variable {

double asNumber() const;
ObjectPtr asObject();
const Common::UString &asString() const;
const Common::UString asString() const;
bool asBoolean() const;

template<typename T> boost::shared_ptr<T> as() const;
Expand Down

0 comments on commit 301d7e0

Please sign in to comment.