1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#ifndef header_js_value
#define header_js_value
#include <string>
#include "js_config.h"
class CL_JSContext;
class CL_JSObject;
class CL_JSClass;
class CL_JSValue
{
// Construction:
public:
CL_JSValue();
CL_JSValue(CL_JSContext *context);
CL_JSValue(const CL_JSValue ©);
CL_JSValue(CL_JSContext *context, jsval &value);
CL_JSValue(CL_JSContext *context, int i);
CL_JSValue(CL_JSContext *context, float f);
CL_JSValue(CL_JSContext *context, double d);
CL_JSValue(CL_JSContext *context, const std::string &str);
CL_JSValue(CL_JSContext *context, const CL_JSObject *obj);
// Attributes:
public:
jsval getJsval() const;
int getInt() const;
bool getBool() const;
float getFloat() const;
double getDouble() const;
CL_JSObject *getObject() const;
std::string getString() const;
operator jsval() const;
operator int() const;
operator bool() const;
operator float() const;
operator double() const;
operator std::string() const;
operator CL_JSObject *() const;
bool isBoolean() const;
bool isDouble() const;
bool isGCThing() const;
bool isInt() const;
bool isNull() const;
bool isNumber() const;
bool isObject() const;
bool isPrimitive() const;
bool isString() const;
bool isVoid() const;
JSType getType() const;
// Operations:
public:
void setJsval(const jsval &value);
void setInt(int i);
void setBool(bool b);
void setFloat(float f);
void setDouble(double d);
void setObject(const CL_JSObject *obj);
void setString(const std::string &str);
void setNull();
void setVoid();
CL_JSValue &operator =(const int &b);
CL_JSValue &operator =(const bool &a);
CL_JSValue &operator =(const float &b);
CL_JSValue &operator =(const double &b);
CL_JSValue &operator =(const std::string &b);
CL_JSValue &operator =(const CL_JSObject *b);
// Implementation:
private:
CL_JSContext *context;
jsval val;
};
#endif
|