27 #include <QtCore/qmetaobject.h> 28 #include <QtCore/qvarlengtharray.h> 29 #include <QtCore/qdebug.h> 30 #include <QtScript/qscriptable.h> 31 #include "../api/qscriptengine_p.h" 32 #include "../api/qscriptable_p.h" 33 #include "../api/qscriptcontext_p.h" 37 #include "PrototypeFunction.h" 38 #include "NativeFunctionWrapper.h" 39 #include "PropertyNameArray.h" 40 #include "JSFunction.h" 44 #include "RegExpObject.h" 45 #include "RegExpConstructor.h" 71 : slotIndex(i), receiver(r), slot(s), senderWrapper(sw) {}
74 bool hasTarget(JSC::JSValue r, JSC::JSValue s)
const 76 if ((r && r.isObject()) != (receiver && receiver.isObject()))
78 if (((r && r.isObject()) && (receiver && receiver.isObject()))
85 void mark(JSC::MarkStack& markStack)
93 if (!JSC::Heap::isCellMarked(scriptObject)) {
100 senderWrapper = JSC::JSValue();
102 markStack.append(senderWrapper);
107 markStack.append(receiver);
109 markStack.append(slot);
117 { connectNotify(signal); }
119 { disconnectNotify(signal); }
128 bool addSignalHandler(
QObject *sender,
int signalIndex,
129 JSC::JSValue receiver,
131 JSC::JSValue senderWrapper,
133 bool removeSignalHandler(
QObject *sender,
int signalIndex,
134 JSC::JSValue receiver,
139 virtual void *qt_metacast(
const char *);
142 void execute(
int slotIndex,
void **argv);
144 void mark(JSC::MarkStack&);
177 const char *signature = method.
signature();
178 const char *s = signature;
179 while (*s && (*s !=
'('))
181 return s - signature;
206 const char *signature,
int nameLength)
208 const char *otherSignature = method.
signature();
209 return !
qstrncmp(otherSignature, signature, nameLength)
210 && (otherSignature[nameLength] ==
'(');
229 return QVariant(targetType, *reinterpret_cast<void* *>(v.
data()));
240 return (JSC::DontDelete
241 | (!prop.
isWritable() ? unsigned(JSC::ReadOnly) : unsigned(0))
242 | (GeneratePropertyFunctions
243 ?
unsigned(JSC::Getter | JSC::Setter)
253 if (scopeIdx != -1) {
254 scope = str.
left(scopeIdx);
255 name = str.
mid(scopeIdx + 2);
269 void *
ptr = qobj->qt_metacast(
"QScriptable");
273 QtFunction::QtFunction(JSC::JSValue
object,
int initialIndex,
bool maybeOverloaded,
274 JSC::JSGlobalData *
data, WTF::PassRefPtr<JSC::Structure> sid,
275 const JSC::Identifier &ident)
276 :
JSC::InternalFunction(data, sid, ident),
277 data(new
Data(object, initialIndex, maybeOverloaded))
288 callData.native.function =
call;
289 return JSC::CallTypeHost;
296 JSC::InternalFunction::markChildren(markStack);
341 method = meta->
method(--index);
384 {
return (m_kind !=
Invalid); }
387 {
return (m_kind == Variant); }
390 {
return (m_kind == MetaType); }
393 {
return (m_kind == Unresolved); }
396 {
return (m_kind == MetaEnum); }
401 {
Q_ASSERT(isMetaEnum());
return m_typeId; }
422 : m_kind(kind), m_typeId(typeId), m_name(name) { }
433 return isMetaEnum() ? 2 : m_typeId;
438 if (!m_name.isEmpty())
440 else if (m_kind == Variant)
451 : m_types(types), m_firstUnresolvedIndex(-1)
456 m_firstUnresolvedIndex = it - m_types.
constBegin();
462 {
return !m_types.isEmpty(); }
465 {
return m_types.at(0); }
468 {
return m_types.count() - 1; }
471 {
return m_types.at(arg + 1); }
474 {
return m_firstUnresolvedIndex == -1; }
477 {
return (m_firstUnresolvedIndex == 0); }
480 {
return m_firstUnresolvedIndex; }
483 {
return m_types.count(); }
486 {
return m_types.at(index); }
505 : matchDistance(dist), index(idx), method(mtd), args(as) { }
510 {
return (index != -1); }
518 return meta->
method(index);
524 QObject *thisQObject,
const JSC::ArgList &scriptArgs,
529 int chosenIndex = -1;
537 const char *initialMethodSignature = 0;
538 exec->clearException();
540 for (index = initialIndex; index >= 0; --
index) {
543 if (index == initialIndex) {
544 initialMethodSignature = method.
signature();
559 if ((rtype == 0) && !returnTypeName.
isEmpty()) {
575 for (
int i = 0; i < parameterTypeNames.
count(); ++i) {
613 bool converted =
true;
614 int matchDistance = 0;
617 if (i < (
int)scriptArgs.size())
618 actual = scriptArgs.at(i);
620 actual = JSC::jsUndefined();
627 exec, actual, argType.
name(),
reinterpret_cast<void* *
>(v.
data()));
633 converted = v.
isValid() || actual.isUndefined() || actual.isNull();
639 if (exec->hadException())
640 return exec->exception();
651 if (converted && (vv.
userType() != tid))
656 && (vvTypeName.
left(vvTypeName.
size()-1) == argType.
name())) {
657 v =
QVariant(tid, *reinterpret_cast<void* *>(vv.
data()));
662 }
else if (actual.isNumber() || actual.isString()) {
673 if (actual.isNumber()) {
693 if (actual.isNumber()) {
725 }
else if (actual.isString()) {
734 }
else if (actual.isBoolean()) {
794 }
else if (actual.isNull()) {
817 && (matchDistance == 0)) {
823 bool redundant =
false;
828 for (
int i = 0; i < candidates.
size(); ++i) {
839 candidates.
append(metaArgs);
847 candidates.
append(metaArgs);
853 conversionFailed.
append(index);
856 if (!maybeOverloaded)
861 if ((chosenIndex == -1) && candidates.
isEmpty()) {
867 if (!conversionFailed.
isEmpty()) {
870 for (
int i = 0; i < conversionFailed.
size(); ++i) {
876 result = JSC::throwError(exec, JSC::TypeError, message);
877 }
else if (!unresolved.
isEmpty()) {
885 if (unresolvedIndex > 0) {
887 arg(unresolvedIndex).arg(unresolvedTypeName));
890 .arg(unresolvedTypeName));
893 result = JSC::throwError(exec, JSC::TypeError, message);
897 for (
int i = 0; i < tooFewArgs.
size(); ++i) {
903 result = JSC::throwError(exec, JSC::SyntaxError, message);
906 if (chosenIndex == -1) {
908 if ((candidates.
size() > 1)
909 && (metaArgs.
args.
count() == candidates.
at(1).args.count())
915 for (
int i = 0; i < candidates.
size(); ++i) {
921 result = JSC::throwError(exec, JSC::TypeError, message);
923 chosenMethod = metaArgs.
method;
924 chosenIndex = metaArgs.
index;
925 args = metaArgs.
args;
929 if (chosenIndex != -1) {
934 void **params = array.
data();
935 for (
int i = 0; i < args.
count(); ++i) {
937 switch (chosenMethod.
type(i).
kind()) {
939 params[i] =
const_cast<QVariant*
>(&v);
944 params[i] =
const_cast<void*
>(v.
constData());
975 if (exec->hadException()) {
976 result = exec->exception() ;
981 }
else if (retType.
typeId() != 0) {
986 result = JSC::jsUndefined();
996 const JSC::ArgList &scriptArgs)
1004 return JSC::throwError(exec, JSC::GeneralError,
QString::fromLatin1(
"cannot call function of deleted QObject"));
1011 delegate =
static_cast<QScriptObject*
>(JSC::asObject(thisValue))->delegate();
1018 if (!meta->
cast(thisQObject)) {
1030 JSC::JSValue thisValue,
const JSC::ArgList &args)
1032 if (!callee->inherits(&QtFunction::info))
1033 return throwError(exec, JSC::TypeError,
"callee is not a QtFunction object");
1038 eng_p->
pushContext(exec, thisValue, args, callee);
1048 JSC::JSGlobalData *
data,
1049 WTF::PassRefPtr<JSC::Structure> sid,
1050 const JSC::Identifier &ident)
1051 :
JSC::InternalFunction(data, sid, ident),
1052 data(new
Data(meta, index))
1063 callData.native.function =
call;
1064 return JSC::CallTypeHost;
1068 JSC::ExecState *exec, JSC::JSObject *callee,
1069 JSC::JSValue thisValue,
const JSC::ArgList &args)
1071 if (!callee->inherits(&QtPropertyFunction::info))
1072 return throwError(exec, JSC::TypeError,
"callee is not a QtPropertyFunction object");
1074 return qfun->
execute(exec, thisValue, args);
1078 JSC::JSValue thisValue,
1079 const JSC::ArgList &args)
1081 JSC::JSValue result = JSC::jsUndefined();
1087 JSC::JSValue qobjectValue = engine->
toUsableValue(thisValue);
1090 && JSC::asObject(qobjectValue)->prototype().isObject()) {
1091 qobjectValue = JSC::asObject(qobjectValue)->prototype();
1098 if (args.size() == 0) {
1120 JSC::JSValue arg = args.at(0);
1139 prop.
write(qobject, v);
1165 const QScriptEngine::QObjectWrapOptions &options)
1166 :
data(new
Data(object, ownership, options))
1195 const JSC::Identifier &propertyName,
1196 JSC::PropertySlot &slot)
1199 #ifndef QT_NO_PROPERTIES 1205 slot.setValue(JSC::throwError(exec, JSC::GeneralError, message));
1214 slot.setGetterSlot(JSC::asObject(it.
value()));
1216 slot.setValue(it.
value());
1221 const QScriptEngine::QObjectWrapOptions &opt =
data->
options;
1232 object, index,
false,
1249 if (GeneratePropertyFunctions) {
1251 meta, index, &exec->globalData(),
1255 slot.setGetterSlot(fun);
1259 val = JSC::jsUndefined();
1269 index = qobject->dynamicPropertyNames().indexOf(name);
1283 object, index,
true,
1294 for (index = 0; index < children.
count(); ++
index) {
1305 #else //QT_NO_PROPERTIES 1307 #endif //QT_NO_PROPERTIES 1312 const JSC::Identifier &propertyName,
1313 JSC::PropertyDescriptor &descriptor)
1316 #ifndef QT_NO_PROPERTIES 1322 descriptor.setValue(JSC::throwError(exec, JSC::GeneralError, message));
1326 const QScriptEngine::QObjectWrapOptions &opt =
data->
options;
1333 if (GeneratePropertyFunctions && ((index = meta->
indexOfProperty(name)) != -1)) {
1337 descriptor.setWritable(
false);
1341 attributes |= JSC::DontEnum;
1342 descriptor.setDescriptor(it.
value(), attributes);
1358 object, index,
false,
1364 attributes |= JSC::DontEnum;
1365 descriptor.setDescriptor(fun, attributes);
1379 if (GeneratePropertyFunctions) {
1381 meta, index, &exec->globalData(),
1385 descriptor.setAccessorDescriptor(fun, fun, attributes);
1386 if (attributes & JSC::ReadOnly)
1387 descriptor.setWritable(
false);
1391 val = JSC::jsUndefined();
1394 descriptor.setDescriptor(val, attributes);
1401 index = qobject->dynamicPropertyNames().indexOf(name);
1415 object, index,
true,
1420 attributes |= JSC::DontEnum;
1421 descriptor.setDescriptor(fun, attributes);
1429 for (index = 0; index < children.
count(); ++
index) {
1434 JSC::ReadOnly | JSC::DontDelete | JSC::DontEnum);
1441 #else //QT_NO_PROPERTIES 1443 #endif //QT_NO_PROPERTIES 1447 const JSC::Identifier& propertyName,
1448 JSC::JSValue
value, JSC::PutPropertySlot &slot)
1450 #ifndef QT_NO_PROPERTIES 1456 JSC::throwError(exec, JSC::GeneralError, message);
1460 const QScriptEngine::QObjectWrapOptions &opt =
data->
options;
1484 if (GeneratePropertyFunctions) {
1495 meta, index, &exec->globalData(),
1500 JSC::CallData callData;
1501 JSC::CallType callType = fun.getCallData(callData);
1502 JSC::JSValue argv[1] = { value };
1503 JSC::ArgList args(argv, 1);
1504 (void)JSC::call(exec, fun, callType, callData,
object, args);
1515 (void)prop.
write(qobject, v);
1533 index = qobject->dynamicPropertyNames().indexOf(name);
1536 (void)qobject->setProperty(name, v);
1541 #endif //QT_NO_PROPERTIES 1545 const JSC::Identifier& propertyName)
1547 #ifndef QT_NO_PROPERTIES 1553 JSC::throwError(exec, JSC::GeneralError, message);
1568 const QScriptEngine::QObjectWrapOptions &opt =
data->
options;
1579 index = qobject->dynamicPropertyNames().indexOf(name);
1581 (void)qobject->setProperty(name,
QVariant());
1586 #else //QT_NO_PROPERTIES 1588 #endif //QT_NO_PROPERTIES 1592 JSC::PropertyNameArray &propertyNames,
1593 JSC::EnumerationMode mode)
1595 #ifndef QT_NO_PROPERTIES 1599 JSC::throwError(exec, JSC::GeneralError, message);
1603 const QScriptEngine::QObjectWrapOptions &opt =
data->
options;
1612 propertyNames.add(JSC::Identifier(exec, name));
1619 for (
int i = 0; i < dpNames.
size(); ++i) {
1621 propertyNames.add(JSC::Identifier(exec, name));
1633 propertyNames.add(JSC::Identifier(exec, sig));
1639 #endif //QT_NO_PROPERTIES 1646 JSC::JSValue val = it.
value();
1648 markStack.append(val);
1666 JSC::JSValue thisValue,
const JSC::ArgList &args)
1671 return throwError(exec, JSC::TypeError,
"this object is not a QObject");
1675 return throwError(exec, JSC::TypeError,
"this object is not a QObject");
1678 if (args.size() != 0)
1679 name = args.
at(0).toString(exec);
1686 JSC::JSValue thisValue,
const JSC::ArgList &args)
1692 return throwError(exec, JSC::TypeError,
"this object is not a QObject");
1696 return throwError(exec, JSC::TypeError,
"this object is not a QObject");
1701 if (args.size() != 0) {
1702 const JSC::JSValue arg = args.
at(0);
1706 JSC::RegExpObject *
const regexp = JSC::asRegExpObject(arg);
1708 const int allChildrenCount = allChildren.
size();
1709 for (
int i = 0; i < allChildrenCount; ++i) {
1710 QObject *
const child = allChildren.
at(i);
1711 const JSC::UString childName = child->
objectName();
1712 JSC::RegExpConstructor* regExpConstructor = engine->
originalGlobalObject()->regExpConstructor();
1715 regExpConstructor->performMatch(regexp->regExp(), childName, 0,
position, length);
1727 const int length = children.
size();
1728 JSC::JSArray *
const result = JSC::constructEmptyArray(exec, length);
1731 for (
int i = 0; i < length; ++i) {
1735 return JSC::JSValue(result);
1739 JSC::JSValue thisValue,
const JSC::ArgList&)
1744 return JSC::jsUndefined();
1748 return JSC::jsUndefined();
1754 return JSC::jsString(exec, str);
1758 JSC::Structure* prototypeFunctionStructure)
1766 putDirectFunction(exec,
new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString,
qobjectProtoFuncToString), JSC::DontEnum);
1767 putDirectFunction(exec,
new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, JSC::Identifier(exec,
"findChild"),
qobjectProtoFuncFindChild), JSC::DontEnum);
1768 putDirectFunction(exec,
new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, JSC::Identifier(exec,
"findChildren"),
qobjectProtoFuncFindChildren), JSC::DontEnum);
1769 this->structure()->setHasGetterSetterProperties(
true);
1775 JSC::ExecState *exec,
const QMetaObject *metaObject, JSC::JSValue ctor,
1776 WTF::PassRefPtr<JSC::Structure> sid)
1777 :
JSC::JSObject(sid),
1781 data->
prototype =
new (exec)JSC::JSObject(exec->lexicalGlobalObject()->emptyObjectStructure());
1790 JSC::ExecState *exec,
const JSC::Identifier& propertyName,
1791 JSC::PropertySlot &slot)
1797 if (propertyName == exec->propertyNames().prototype) {
1799 slot.setValue(
data->
ctor.get(exec, propertyName));
1809 for (
int j = 0; j < e.
keyCount(); ++j) {
1810 const char *
key = e.
key(j);
1812 slot.setValue(JSC::JSValue(exec, e.
value(j)));
1818 return JSC::JSObject::getOwnPropertySlot(exec, propertyName, slot);
1822 JSC::ExecState* exec,
const JSC::Identifier& propertyName,
1823 JSC::PropertyDescriptor& descriptor)
1829 if (propertyName == exec->propertyNames().prototype) {
1830 descriptor.setDescriptor(
data->
ctor 1831 ?
data->
ctor.get(exec, propertyName)
1833 JSC::DontDelete | JSC::DontEnum);
1841 for (
int j = 0; j < e.
keyCount(); ++j) {
1842 const char *
key = e.
key(j);
1844 descriptor.setDescriptor(JSC::JSValue(exec, e.
value(j)),
1845 JSC::ReadOnly | JSC::DontDelete);
1851 return JSC::JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
1855 JSC::JSValue
value, JSC::PutPropertySlot &slot)
1857 if (propertyName == exec->propertyNames().prototype) {
1859 data->
ctor.put(exec, propertyName, value, slot);
1869 for (
int j = 0; j < e.
keyCount(); ++j) {
1875 JSC::JSObject::put(exec, propertyName, value, slot);
1879 JSC::ExecState *exec,
const JSC::Identifier& propertyName)
1881 if (propertyName == exec->propertyNames().prototype)
1888 for (
int j = 0; j < e.
keyCount(); ++j) {
1894 return JSC::JSObject::deleteProperty(exec, propertyName);
1898 JSC::PropertyNameArray &propertyNames,
1899 JSC::EnumerationMode mode)
1906 for (
int j = 0; j < e.
keyCount(); ++j)
1907 propertyNames.add(JSC::Identifier(exec, e.
key(j)));
1909 JSC::JSObject::getOwnPropertyNames(exec, propertyNames, mode);
1918 JSC::JSObject::markChildren(markStack);
1923 callData.native.function =
call;
1924 return JSC::CallTypeHost;
1929 constructData.native.function =
construct;
1930 return JSC::ConstructTypeHost;
1934 JSC::ExecState *exec, JSC::JSObject *callee,
1935 JSC::JSValue thisValue,
const JSC::ArgList &args)
1939 if (!callee->inherits(&QMetaObjectWrapperObject::info))
1940 return throwError(exec, JSC::TypeError,
"callee is not a QMetaObject");
1943 eng_p->
pushContext(exec, thisValue, args, callee);
1944 JSC::JSValue result =
self->execute(eng_p->
currentFrame, args);
1955 eng_p->
pushContext(exec, JSC::JSValue(), args, callee,
true);
1956 JSC::JSValue result =
self->execute(eng_p->
currentFrame, args);
1959 if (!result || !result.isObject())
1961 return JSC::asObject(result);
1965 const JSC::ArgList &args)
1970 JSC::CallData callData;
1971 JSC::CallType callType =
data->
ctor.getCallData(callData);
1989 if (!exec->hadException()) {
2001 return JSC::throwError(exec, JSC::TypeError, message);
2013 JSC::ExecState *exec, JSC::JSObject*, JSC::JSValue thisValue,
const JSC::ArgList&)
2017 if (!thisValue.inherits(&QMetaObjectWrapperObject::info))
2018 return throwError(exec, JSC::TypeError,
"this object is not a QMetaObject");
2020 return JSC::jsString(exec, meta->
className());
2024 JSC::ExecState *exec, WTF::PassRefPtr<JSC::Structure> structure,
2025 JSC::Structure* prototypeFunctionStructure)
2028 putDirectFunction(exec,
new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, JSC::Identifier(exec,
"className"),
qmetaobjectProtoFuncClassName), JSC::DontEnum);
2042 35, 34, 34, 34, 0x0a,
2048 "QScript::QObjectConnectionManager\0\0execute()\0" 2058 return &staticMetaObject;
2063 if (!_clname)
return 0;
2064 if (!strcmp(_clname, qt_meta_stringdata_QObjectConnectionManager))
2066 return QObject::qt_metacast(_clname);
2071 _id = QObject::qt_metacall(_c, _id, _a);
2083 JSC::JSValue receiver;
2085 JSC::JSValue senderWrapper;
2086 int signalIndex = -1;
2088 for (
int i = 0; i < connections.size(); ++i) {
2090 for (
int j = 0; j < cs.
size(); ++j) {
2109 if (engine->isCollecting()) {
2110 qWarning(
"QtScript: can't execute signal handler during GC");
2117 QScriptFunction *fun = engine->convertToNativeFunction(slot);
2131 int argc = parameterTypes.
count();
2133 JSC::ExecState *exec = engine->currentFrame;
2135 for (
int i = 0; i < argc; ++i) {
2136 JSC::JSValue actual;
2137 void *arg = argv[i + 1];
2141 qWarning(
"QScriptEngine: Unable to handle unregistered datatype '%s' " 2142 "when invoking handler of signal %s::%s",
2144 actual = JSC::jsUndefined();
2150 argsVector[i] = actual;
2152 JSC::ArgList jscArgs(argsVector.
data(), argsVector.
size());
2154 JSC::JSValue senderObject;
2156 senderObject = senderWrapper;
2162 JSC::JSValue thisObject;
2163 if (receiver && receiver.isObject())
2164 thisObject = receiver;
2166 thisObject = engine->globalObject();
2168 JSC::CallData callData;
2169 JSC::CallType callType = slot.getCallData(callData);
2170 if (exec->hadException())
2171 exec->clearException();
2172 JSC::call(exec, slot, callType, callData, thisObject, jscArgs);
2174 if (exec->hadException()) {
2175 if (slot.inherits(&QtFunction::info) && !
static_cast<QtFunction*
>(JSC::asObject(slot))->qobject()) {
2178 removeSignalHandler(sender(), signalIndex, receiver, slot);
2179 exec->clearException();
2181 engine->emitSignalHandlerException();
2187 : engine(eng), slotCounter(0)
2199 for (
int j = 0; j < cs.
size(); ++j)
2200 cs[j].
mark(markStack);
2206 JSC::JSValue
function, JSC::JSValue senderWrapper,
2218 signalString.
append(
'2');
2227 JSC::JSValue receiver, JSC::JSValue slot)
2232 for (
int i = 0; i < cs.
size(); ++i) {
2241 signalString.
append(
'2');
2252 :
engine(eng), connectionManager(0)
2274 markStack.append(info.
object);
2282 JSC::JSValue receiver,
2284 JSC::JSValue senderWrapper,
2290 sender, signalIndex, receiver, slot, senderWrapper, type);
2295 JSC::JSValue receiver,
2301 sender, signalIndex, receiver, slot);
2305 const QScriptEngine::QObjectWrapOptions &options)
const 2317 const QScriptEngine::QObjectWrapOptions &options)
2331 #include "moc_qscriptqobject_p.cpp" The QVariant class acts like a union for the most common Qt data types.
The QScriptContext class represents a Qt Script function invocation.
static QVariant variantFromValue(JSC::ExecState *exec, int targetType, JSC::JSValue value)
QList< QScript::QObjectWrapperInfo > wrappers
QScriptEnginePrivate * engine
void mark(JSC::MarkStack &markStack)
QScriptObject * wrapperObject() const
QScriptEnginePrivate * engine
virtual bool deleteProperty(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName)
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
virtual void getOwnPropertyNames(QScriptObject *, JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
static mach_timebase_info_data_t info
virtual Type type() const =0
bool removeSignalHandler(QObject *sender, int signalIndex, JSC::JSValue receiver, JSC::JSValue slot)
#define QT_END_NAMESPACE
This macro expands to.
JSC::JSValue execute(JSC::ExecState *exec, JSC::JSValue thisValue, const JSC::ArgList &args)
QObjectDelegate(QObject *object, QScriptEngine::ValueOwnership ownership, const QScriptEngine::QObjectWrapOptions &options)
static JSC::JSValue jscValueFromVariant(JSC::ExecState *, const QVariant &value)
static JSC::JSValue JSC_HOST_CALL call(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
const QChar at(int i) const
Returns the character at the given index position in the string.
static const JSC::ClassInfo info
void remove(int i)
Removes the element at index position i.
bool addSignalHandler(QObject *sender, int signalIndex, JSC::JSValue receiver, JSC::JSValue slot, JSC::JSValue senderWrapper, Qt::ConnectionType type)
#define it(className, varName)
virtual void markChildren(QScriptObject *, JSC::MarkStack &markStack)
QObject * qobject() const
static QScriptEnginePrivate * get(QScriptEngine *q)
QByteArray & append(char c)
Appends the character ch to this byte array.
virtual int qt_metacall(QMetaObject::Call, int, void **argv)
ASSERT_CLASS_FITS_IN_CELL(::QScript::QScriptActivationObject)
static QVariant toVariant(JSC::ExecState *, JSC::JSValue)
static JSC::JSValue create(JSC::ExecState *, int type, const void *ptr)
virtual bool deleteProperty(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName)
static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType callType, QObject *thisQObject, const JSC::ArgList &scriptArgs, const QMetaObject *meta, int initialIndex, bool maybeOverloaded)
QString objectName
the name of this object
QObjectPrototype(JSC::ExecState *, WTF::PassRefPtr< JSC::Structure >, JSC::Structure *prototypeFunctionStructure)
T & first()
Returns a reference to the first item in the vector.
static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChildren(JSC::ExecState *exec, JSC::JSObject *, JSC::JSValue thisValue, const JSC::ArgList &args)
The QByteArray class provides an array of bytes.
QScriptEngine::ValueOwnership ownership() const
bool removeSignalHandler(QObject *sender, int signalIndex, JSC::JSValue receiver, JSC::JSValue slot)
virtual void markChildren(QScriptObject *, JSC::MarkStack &markStack)
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
JSC::CallFrame * pushContext(JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList &args, JSC::JSObject *callee, bool calledAsConstructor=false, bool clearScopeChain=false)
JSC native function doesn't have different stackframe or context.
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
QPointer< QObject > value
static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChild(JSC::ExecState *exec, JSC::JSObject *, JSC::JSValue thisValue, const JSC::ArgList &args)
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
static QObject * toQObject(JSC::ExecState *, JSC::JSValue)
QScriptObjectDelegate * delegate() const
virtual bool getOwnPropertyDescriptor(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertyDescriptor &)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QObjectConnection(int i, JSC::JSValue r, JSC::JSValue s, JSC::JSValue sw)
static int indexOfMetaEnum(const QMetaObject *meta, const QByteArray &str)
virtual JSC::CallType getCallData(JSC::CallData &)
int count(const T &t) const
Returns the number of occurrences of value in the list.
bool hasDemarshalFunction(int type) const
static const JSC::ClassInfo info
The QString class provides a Unicode character string.
virtual void put(QScriptObject *, JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue, JSC::PutPropertySlot &)
void callDisconnectNotify(const char *signal)
The QHash class is a template class that provides a hash-table-based dictionary.
void setValue(const T &value)
Stores a copy of value.
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
bool addSignalHandler(QObject *sender, int signalIndex, JSC::JSValue receiver, JSC::JSValue slot, JSC::JSValue senderWrapper, Qt::ConnectionType type)
QScriptEngine::FunctionWithArgSignature function() const
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
virtual void * qt_metacast(const char *)
const T value(const Key &key) const
Returns the value associated with the key.
JSC::ExecState * currentFrame
void resize(int size)
Sets the size of the vector to size.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncToString(JSC::ExecState *exec, JSC::JSObject *, JSC::JSValue thisValue, const JSC::ArgList &)
The QScriptable class provides access to the Qt Script environment from Qt C++ member functions...
static QScriptablePrivate * get(QScriptable *q)
virtual bool getOwnPropertySlot(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
static const JSC::ClassInfo info
virtual void markChildren(JSC::MarkStack &)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
void setOwnership(QScriptEngine::ValueOwnership ownership)
static bool convertToNativeQObject(JSC::ExecState *, JSC::JSValue, const QByteArray &targetType, void **result)
void mark(JSC::MarkStack &)
void append(const T &t)
Inserts value at the end of the list.
The QScriptEngine class provides an environment for evaluating Qt Script code.
QVector< QVector< QObjectConnection > > connections
static bool isVariant(JSC::JSValue)
static qint32 toInt32(JSC::ExecState *, JSC::JSValue)
virtual void getOwnPropertyNames(QScriptObject *, JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
#define QT_BEGIN_NAMESPACE
This macro expands to.
JSC::JSValue data() const
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
bool canConvert(Type t) const
Returns true if the variant's type can be cast to the requested type, t.
static QScriptable * scriptableFromQObject(QObject *qobj)
virtual ~QtPropertyFunction()
QScriptEngine::ValueOwnership ownership
static QScriptContext * contextForFrame(JSC::ExecState *frame)
JSC::JSGlobalObject * originalGlobalObject() const
static const char qt_meta_stringdata_QObjectConnectionManager[]
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
static JSC::UString toString(JSC::ExecState *, JSC::JSValue)
QObjectConnectionManager(QScriptEnginePrivate *engine)
const T & at(int i) const
Returns the item at index position i in the list.
void mark(JSC::MarkStack &)
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
void append(const T &t)
Inserts value at the end of the vector.
static Type type(const QScriptValue &v)
Q_CORE_EXPORT void qWarning(const char *,...)
static bool methodNameEquals(const QMetaMethod &method, const char *signature, int nameLength)
Returns true if the name of the given method is the same as that specified by the (signature...
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 ...
static const char * data(const QByteArray &arr)
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Type
This enum type defines the types of variable that a QVariant can contain.
QScript::QObjectConnectionManager * connectionManager
JSC::JSValue execute(JSC::ExecState *exec, JSC::JSValue thisValue, const JSC::ArgList &args)
ValueOwnership
This enum specifies the ownership when wrapping a C++ value, e.
virtual void put(QScriptObject *, JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue, JSC::PutPropertySlot &)
static QMetaMethod metaMethod(const QMetaObject *meta, QMetaMethod::MethodType type, int index)
virtual bool getOwnPropertyDescriptor(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertyDescriptor &)
QHash< QByteArray, JSC::JSValue > cachedMembers
const T * ptr(const T &t)
QScriptObject * findWrapper(QScriptEngine::ValueOwnership ownership, const QScriptEngine::QObjectWrapOptions &options) const
const QMetaObject * metaObject() const
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
const char * typeName() const
Returns the name of the type stored in the variant.
ASSERT_CLASS_FITS_IN_CELL(QScript::QtPropertyFunction)
bool hasTarget(JSC::JSValue r, JSC::JSValue s) const
QtPropertyFunction(const QMetaObject *meta, int index, JSC::JSGlobalData *, WTF::PassRefPtr< JSC::Structure >, const JSC::Identifier &)
const T & at(int i) const
Returns the item at index position i in the vector.
JSC::JSValue newVariant(const QVariant &)
bool convert(Type t)
Casts the variant to the requested type, t.
static JSC::JSValue JSC_HOST_CALL qmetaobjectProtoFuncClassName(JSC::ExecState *exec, JSC::JSObject *, JSC::JSValue thisValue, const JSC::ArgList &)
int length() const
Same as size().
QScriptEngine::ValueOwnership ownership
static const QMetaObject staticMetaObject
static bool hasMethodAccess(const QMetaMethod &method, int index, const QScriptEngine::QObjectWrapOptions &opt)
const char * constData() const
Returns a pointer to the data stored in the byte array.
static bool convertValue(JSC::ExecState *, JSC::JSValue value, int type, void *ptr)
static unsigned flagsForMetaProperty(const QMetaProperty &prop)
static bool isDate(JSC::JSValue)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
virtual Type type() const
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
static bool isRegExp(JSC::JSValue)
#define Q_ASSERT_X(cond, where, what)
static int methodNameLength(const QMetaMethod &method)
Calculates the length of the name of the given method by looking for the first '(' character...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
int userType() const
Returns the storage type of the value stored in the variant.
QString & append(QChar c)
~QObjectConnectionManager()
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
static bool isEnumerableMetaProperty(const QMetaProperty &prop, const QMetaObject *mo, int index)
static const bool GeneratePropertyFunctions
virtual bool getOwnPropertySlot(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
QObjectData(QScriptEnginePrivate *engine)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
QList< QByteArray > dynamicPropertyNames() const
Returns the names of all properties that were dynamically added to the object using setProperty()...
static bool isQObject(JSC::JSValue)
QObject * parent() const
Returns a pointer to the parent object.
bool maybeOverloaded() const
const void * constData() const
int size() const
Returns the number of items in the list.
static const JSC::ClassInfo info
static QByteArray methodName(const char *signature, int nameLength)
Makes a deep copy of the first nameLength characters of the given method signature and returns the co...
int qstrncmp(const char *str1, const char *str2, uint len)
const QObjectList & children() const
Returns a list of child objects.
static const char * get(QDBusError::ErrorType code)
JSC::JSValue newQObject(QObject *object, QScriptEngine::ValueOwnership ownership=QScriptEngine::QtOwnership, const QScriptEngine::QObjectWrapOptions &options=0)
int size() const
Returns the number of bytes in this byte array.
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
static QVariant & variantValue(JSC::JSValue value)
const QMetaObject * metaObject() const
QScriptEngine::QObjectWrapOptions options
static JSC::JSValue JSC_HOST_CALL call(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
int mostGeneralMethod(QMetaMethod *out=0) const
const T * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
void setDelegate(QScriptObjectDelegate *delegate)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
T * data()
Returns a pointer to the data stored in the vector.
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
int qstrcmp(const QByteArray &str1, const char *str2)
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
virtual bool compareToObject(QScriptObject *, JSC::ExecState *, JSC::JSObject *)
QScriptEngine::QObjectWrapOptions options
QList< int > overloadedIndexes() const
static bool isArray(JSC::JSValue)
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
void callConnectNotify(const char *signal)
void prepend(const T &t)
Inserts value at the beginning of the vector.
The QScriptValue class acts as a container for the Qt Script data types.
static const JSC::ClassInfo info
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void execute(int slotIndex, void **argv)
int size() const
Returns the number of items in the vector.
JSC::JSValue senderWrapper
virtual JSC::CallType getCallData(JSC::CallData &)
QList< T > findChildren(const QString &aName=QString()) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
static QVariant jscValueToVariant(JSC::ExecState *, JSC::JSValue value, int targetType)
QByteArray convertToLatin1(const JSC::UString &str)
static const uint qt_meta_data_QObjectConnectionManager[]
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
void registerWrapper(QScriptObject *wrapper, QScriptEngine::ValueOwnership ownership, const QScriptEngine::QObjectWrapOptions &options)
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
int propertyIndex() const