19 #ifndef GNASH_AS_VALUE_H 20 #define GNASH_AS_VALUE_H 24 #include <boost/variant.hpp> 26 #include <type_traits> 52 static const double NaN = std::numeric_limits<double>::quiet_NaN();
58 return isNaN(num - num);
122 _value(
boost::blank())
136 : _type(other._type),
137 _value(
std::move(other._value))
139 other._type = UNDEFINED;
148 _value(
std::string(str))
155 _value(
std::move(str))
159 template <
typename T,
typename U =
160 typename std::enable_if<std::is_same<bool, T>::value>
::type>
193 _value = std::move(other._value);
194 other._type = UNDEFINED;
201 const char* typeOf()
const;
204 bool is_function()
const;
208 return _type == STRING;
213 return _type == NUMBER;
220 return _type == OBJECT || _type == DISPLAYOBJECT;
225 return _type == DISPLAYOBJECT;
236 DSOTEXPORT std::string to_string(
int version = 7)
const;
241 double to_number(
int version)
const;
277 MovieClip* toMovieClip(
bool skipRebinding =
false)
const;
294 DisplayObject* toDisplayObject(
bool skipRebinding =
false)
const;
302 AsType defaultPrimitive(
int version)
const;
319 void set_string(
const std::string& str);
322 void set_double(
double val);
325 void set_bool(
bool val);
331 void set_undefined();
337 return (_type == UNDEFINED);
341 return (_type == NULLTYPE);
345 return (_type == BOOLEAN);
349 return (_type == UNDEFINED_EXCEPT || _type == NULLTYPE_EXCEPT
350 || _type == BOOLEAN_EXCEPT || _type == NUMBER_EXCEPT
351 || _type == OBJECT_EXCEPT || _type == DISPLAYOBJECT_EXCEPT
352 || _type == STRING_EXCEPT);
358 if (!is_exception()) {
359 _type =
static_cast<AsType>(
static_cast<int>(_type) + 1);
364 if (is_exception()) {
365 _type =
static_cast<AsType>(
static_cast<int>(_type) - 1);
391 void setReachable()
const;
421 typedef boost::variant<boost::blank,
439 bool equalsSameType(
const as_value& v)
const;
448 as_object* getObj()
const;
453 DisplayObject* getCharacter(
bool skipRebinding =
false)
const;
458 CharacterProxy getCharacterProxy()
const;
463 double getNum()
const {
464 assert(_type == NUMBER);
465 return boost::get<double>(_value);
471 bool getBool()
const {
472 assert(_type == BOOLEAN);
473 return boost::get<bool>(_value);
479 const std::string& getStr()
const {
480 assert(_type == STRING);
481 return boost::get<std::string>(_value);
530 #endif // GNASH_AS_VALUE_H primitive_types
These are the primitive types, see the ECMAScript reference.
Definition: as_value.h:63
Definition: GnashKey.h:150
bool isNaN(const T &num)
Definition: GnashNumeric.h:62
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:83
bool is_string() const
Return true if this value is a string.
Definition: as_value.h:207
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
bool is_number() const
Return true if this value is strictly a number.
Definition: as_value.h:212
bool is_sprite() const
Return true if this value is a DISPLAYOBJECT.
Definition: as_value.h:224
ActionScript value type.
Definition: as_value.h:94
Definition: as_value.h:108
void setNaN(as_value &v)
Set a value to NaN.
Definition: as_value.h:524
std::string doubleToString(double val, int radix)
Convert numeric value to string value, following ECMA-262 specification.
Definition: as_value.cpp:832
Definition: as_value.h:104
DSOEXPORT as_value & operator=(const as_value &v)
Assign to an as_value.
Definition: as_value.h:183
Definition: as_value.h:106
bool operator==(const event_id &a, const event_id &b)
Return whether two event_ids are equal.
Definition: event_id.h:163
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
A class to compose AMF buffers.
Definition: AMFConverter.h:55
as_value(double num)
Construct a primitive Number value.
Definition: as_value.h:168
type
Definition: GnashKey.h:329
DSOEXPORT as_value(std::string str)
Construct a primitive String value.
Definition: as_value.h:152
Definition: as_value.h:102
Definition: as_value.h:105
Definition: as_value.h:103
bool is_bool() const
Definition: as_value.h:344
The base class for all ActionScript objects.
Definition: as_object.h:161
~as_value()
Definition: as_value.h:142
Definition: GnashKey.h:161
Definition: as_value.h:66
bool is_null() const
Definition: as_value.h:340
bool operator!=(const SWFCxForm &a, const SWFCxForm &b)
Definition: SWFCxForm.h:91
Definition: as_value.h:107
AsType
Definition: as_value.h:100
std::ostream & operator<<(std::ostream &o, const URL &u)
Definition: URL.cpp:447
DSOEXPORT as_value(as_value &&other)
Move constructor.
Definition: as_value.h:135
bool isInf(const T &num)
Definition: as_value.h:56
A proxy for DisplayObject pointers.
Definition: CharacterProxy.h:43
Definition: as_value.h:113
Definition: as_value.h:110
Definition: as_value.h:114
bool equals(const as_value &a, const as_value &b, const VM &vm)
Check if two values are equal.
Definition: VM.cpp:439
as_value(as_object *obj)
Construct a null, Object, or DisplayObject value.
Definition: as_value.h:175
Definition: as_value.h:109
DSOEXPORT as_value()
Construct an undefined value.
Definition: as_value.h:119
#define DSOEXPORT
Definition: dsodefs.h:55
Definition: GnashKey.h:133
Definition: as_value.h:67
The AVM1 virtual machine.
Definition: VM.h:71
Definition: GnashKey.h:132
bool parseNonDecimalInt(const std::string &s, double &d, bool whole)
Definition: as_value.cpp:793
Definition: as_value.h:111
void set_double(double val)
Set to a primitive number.
Definition: as_value.cpp:739
void flag_exception()
Definition: as_value.h:357
bool is_undefined() const
Definition: as_value.h:336
#define DSOTEXPORT
Definition: dsodefs.h:63
void unflag_exception()
Definition: as_value.h:363
bool is_object() const
Return true if this value is an object.
Definition: as_value.h:219
DSOEXPORT as_value(const char *str)
Construct a primitive String value.
Definition: as_value.h:145
as_value(T val)
Construct a primitive Boolean value.
Definition: as_value.h:161
Definition: GnashKey.h:165
Definition: as_value.h:65
bool is_exception() const
Definition: as_value.h:348
Definition: as_value.h:112
DSOEXPORT as_value(const as_value &v)
Copy constructor.
Definition: as_value.h:127
DSOEXPORT as_value & operator=(as_value &&other)
Definition: as_value.h:190
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:62