27 #include "../api/qscriptengine.h" 28 #include "../api/qscriptengine_p.h" 31 #include "PrototypeFunction.h" 32 #include "JSFunction.h" 33 #include "NativeFunctionWrapper.h" 47 QVariantDelegate::QVariantDelegate(
const QVariant &value)
72 JSC::JSValue thisValue,
const JSC::ArgList&)
77 return throwError(exec, JSC::TypeError);
80 return throwError(exec, JSC::TypeError);
84 return JSC::jsUndefined();
86 return JSC::jsString(exec, v.
toString());
89 return JSC::jsNumber(exec, v.
toInt());
92 return JSC::jsBoolean(v.
toBool());
95 return JSC::jsNumber(exec, v.
toDouble());
101 return JSC::jsNumber(exec, v.
toUInt());
110 JSC::JSValue thisValue,
const JSC::ArgList &args)
115 return throwError(exec, JSC::TypeError,
"This object is not a QVariant");
118 return throwError(exec, JSC::TypeError,
"This object is not a QVariant");
122 if (value.isObject()) {
127 result = value.toString(exec);
129 return JSC::jsString(exec, result);
139 JSC::Structure* prototypeFunctionStructure)
144 putDirectFunction(exec,
new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString,
variantProtoFuncToString), JSC::DontEnum);
145 putDirectFunction(exec,
new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf,
variantProtoFuncValueOf), JSC::DontEnum);
The QVariant class acts like a union for the most common Qt data types.
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
virtual Type type() const =0
#define QT_END_NAMESPACE
This macro expands to.
ASSERT_CLASS_FITS_IN_CELL(::QScript::QScriptActivationObject)
static QVariant toVariant(JSC::ExecState *, JSC::JSValue)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
static const JSC::ClassInfo info
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool canConvert(Type t) const
Returns true if the variant's type can be cast to the requested type, t.
JSC::JSValue toUsableValue(JSC::JSValue value)
If the given value is the original global object, returns the custom global object or a proxy to the ...
QVariantPrototype(JSC::ExecState *, WTF::PassRefPtr< JSC::Structure >, JSC::Structure *prototypeFunctionStructure)
static JSC::JSValue JSC_HOST_CALL variantProtoFuncValueOf(JSC::ExecState *exec, JSC::JSObject *, JSC::JSValue thisValue, const JSC::ArgList &)
const char * typeName() const
Returns the name of the type stored in the variant.
virtual bool compareToObject(QScriptObject *, JSC::ExecState *, JSC::JSObject *)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
void setValue(const QVariant &value)
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
void setDelegate(QScriptObjectDelegate *delegate)
static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec, JSC::JSObject *callee, JSC::JSValue thisValue, const JSC::ArgList &args)