本文整理汇总了C++中QScriptValue::objectId方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValue::objectId方法的具体用法?C++ QScriptValue::objectId怎么用?C++ QScriptValue::objectId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValue
的用法示例。
在下文中一共展示了QScriptValue::objectId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expandObject
QList<JSAgentWatchData> QJSDebuggerAgentPrivate::getLocals(QScriptContext *ctx)
{
QList<JSAgentWatchData> locals;
if (ctx) {
QScriptValue activationObject = ctx->activationObject();
QScriptValue thisObject = ctx->thisObject();
locals = expandObject(activationObject);
if (thisObject.isObject()
&& thisObject.objectId() != engine()->globalObject().objectId()
&& QScriptValueIterator(thisObject).hasNext())
locals.prepend(fromScriptValue(QLatin1String("this"), thisObject));
recordKnownObjects(locals);
knownObjectIds << activationObject.objectId();
}
return locals;
}
示例2: GetObjectInformation
void JavascriptInstance::GetObjectInformation(const QScriptValue &object, QSet<qint64> &ids, uint &valueCount, uint &objectCount, uint &nullCount, uint &numberCount,
uint &boolCount, uint &stringCount, uint &arrayCount, uint &funcCount, uint &qobjCount, uint &qobjMethodCount)
{
if (!ids.contains(object.objectId()))
ids << object.objectId();
QScriptValueIterator iter(object);
while(iter.hasNext())
{
iter.next();
QScriptValue v = iter.value();
if (ids.contains(v.objectId()))
continue;
ids << v.objectId();
valueCount++;
if (v.isNull())
nullCount++;
if (v.isNumber())
numberCount++;
else if (v.isBool())
boolCount++;
else if (v.isString())
stringCount++;
else if (v.isArray())
arrayCount++;
else if (v.isFunction())
funcCount++;
else if (v.isQObject())
qobjCount++;
if (v.isObject())
objectCount++;
if (v.isQMetaObject())
qobjMethodCount += v.toQMetaObject()->methodCount();
// Recurse
if ((v.isObject() || v.isArray()) && !v.isFunction() && !v.isString() && !v.isNumber() && !v.isBool() && !v.isQObject() && !v.isQMetaObject())
GetObjectInformation(v, ids, valueCount, objectCount, nullCount, numberCount, boolCount, stringCount, arrayCount, funcCount, qobjCount, qobjMethodCount);
}
}
示例3: fromScriptValue
static JSAgentWatchData fromScriptValue(const QString &expression,
const QScriptValue &value)
{
static const QString arrayStr = QCoreApplication::translate
("Debugger::JSAgentWatchData", "[Array of length %1]");
static const QString undefinedStr = QCoreApplication::translate
("Debugger::JSAgentWatchData", "<undefined>");
JSAgentWatchData data;
data.exp = expression.toUtf8();
data.name = data.exp;
data.hasChildren = false;
data.value = value.toString().toUtf8();
data.objectId = value.objectId();
if (value.isArray()) {
data.type = "Array";
data.value = arrayStr.arg(value.property(QLatin1String("length")).toString()).toUtf8();
data.hasChildren = true;
} else if (value.isBool()) {
data.type = "Bool";
// data.value = value.toBool() ? "true" : "false";
} else if (value.isDate()) {
data.type = "Date";
data.value = value.toDateTime().toString().toUtf8();
} else if (value.isError()) {
data.type = "Error";
} else if (value.isFunction()) {
data.type = "Function";
} else if (value.isUndefined()) {
data.type = undefinedStr.toUtf8();
} else if (value.isNumber()) {
data.type = "Number";
} else if (value.isRegExp()) {
data.type = "RegExp";
} else if (value.isString()) {
data.type = "String";
} else if (value.isVariant()) {
data.type = "Variant";
} else if (value.isQObject()) {
const QObject *obj = value.toQObject();
data.type = "Object";
data.value += '[';
data.value += obj->metaObject()->className();
data.value += ']';
data.hasChildren = true;
} else if (value.isObject()) {
data.type = "Object";
data.hasChildren = true;
data.value = "[Object]";
} else if (value.isNull()) {
data.type = "<null>";
} else {
data.type = "<unknown>";
}
return data;
}
示例4: unsubscribe
void MessageHandler::unsubscribe( const QString& message, const QScriptValue& receiver, const QScriptValue& /* thisObject */ )
{
QMultiHash<QString, QScriptValue>::iterator itr;
for( itr = d->subscribedFunctions.find( message ); itr != d->subscribedFunctions.end() && itr.key() == message; ++itr )
{
if( itr.value().equals( receiver ) )
break;
}
if( itr != d->subscribedFunctions.end() && itr.key() == message )
{
d->subscribedFunctions.erase( itr );
d->functionObjects.remove( receiver.objectId() );
}
}
示例5: property
QScriptValue ScriptDataItem::property(const QScriptValue &object, const QScriptString &name, uint id)
{
Q_UNUSED(id);
if (name == m_subitem)
return m_subitemFunc;
if (name == m_subitems)
return m_subitemsFunc;
DataItem *item = get_data_item(object);
debug() << Q_FUNC_INFO << item << (object.objectId() == m_prototype.objectId());
Q_ASSERT(item);
QVariant data = item->property(name.toString().toUtf8());
if (data.isNull()) {
DataItem subitem = item->subitem(name.toString());
if (!subitem.isNull())
return engine()->toScriptValue(subitem);
return engine()->undefinedValue();
}
return engine()->newVariant(data);
}
示例6: translateFileConfig
QScriptValue Transformer::translateFileConfig(ScriptEngine *scriptEngine, const Artifact *artifact,
const QString &defaultModuleName)
{
QScriptValue obj = scriptEngine->newObject();
attachPointerTo(obj, artifact);
ModuleProperties::init(obj, artifact);
obj.setProperty(StringConstants::fileNameProperty(), artifact->fileName());
obj.setProperty(StringConstants::filePathProperty(), artifact->filePath());
setArtifactProperty(obj, StringConstants::baseNameProperty(), js_baseName, artifact);
setArtifactProperty(obj, StringConstants::completeBaseNameProperty(), js_completeBaseName,
artifact);
setArtifactProperty(obj, QStringLiteral("baseDir"), js_baseDir, artifact);
setArtifactProperty(obj, QStringLiteral("children"), js_children, artifact);
const QStringList fileTags = sorted(artifact->fileTags().toStringList());
scriptEngine->setObservedProperty(obj, StringConstants::fileTagsProperty(),
scriptEngine->toScriptValue(fileTags));
scriptEngine->observer()->addArtifactId(obj.objectId());
if (!defaultModuleName.isEmpty())
obj.setProperty(StringConstants::moduleNameProperty(), defaultModuleName);
return obj;
}
示例7: subscribe
void MessageHandler::subscribe( const QString& message, const QScriptValue& receiver, const QScriptValue& thisObject )
{
d->subscribedFunctions.insert( message, receiver );
d->functionObjects.insert( receiver.objectId(), thisObject );
}