43 #include "private/qdeclarativecontext_p.h" 45 #include "private/qdeclarativecomponent_p.h" 46 #include "private/qdeclarativeexpression_p.h" 47 #include "private/qdeclarativeengine_p.h" 49 #include "private/qdeclarativecompiledbindings_p.h" 51 #include "private/qdeclarativeglobalscriptclass_p.h" 54 #include <QtCore/qvarlengtharray.h> 55 #include <QtCore/qdebug.h> 57 #include <private/qscriptdeclarativeclass_p.h> 62 :
data(0), notifyIndex(-1)
222 if (!
d->data->isInternal)
235 return d->data &&
d->data->isValid();
245 return d->data->engine;
255 return d->data->parent?
d->data->parent->asQDeclarativeContext():0;
264 return d->data->contextObject;
277 qWarning(
"QDeclarativeContext: Cannot set context object for internal context.");
282 qWarning(
"QDeclarativeContext: Cannot set context object on invalid context.");
295 if (
d->notifyIndex == -1)
301 qWarning(
"QDeclarativeContext: Cannot set property on internal context.");
306 qWarning(
"QDeclarativeContext: Cannot set property on invalid context.");
324 d->propertyValues.append(value);
328 d->propertyValues[idx] = value;
341 if (
d->notifyIndex == -1)
347 qWarning(
"QDeclarativeContext: Cannot set property on internal context.");
352 qWarning(
"QDeclarativeContext: Cannot set property on invalid context.");
398 if (idx >=
d->propertyValues.count())
401 value =
d->propertyValues[idx];
416 return d->data->resolvedUrl(src);
505 imports(0), childContexts(0), nextChild(0), prevChild(0), expressions(0), contextObjects(0),
506 contextGuards(0), idValues(0), idValueCount(0), optimizedBindings(0), linkedContext(0),
569 expression = nextExpression;
594 while (contextGuard) {
596 contextGuard->m_next = 0;
597 contextGuard->m_prev = 0;
598 contextGuard->m_contextData = 0;
678 const QDeclarativeParser::Object::ScriptBlock::Pragmas &pragmas = script.
pragmas;
694 scriptEngine->
evaluate(code, url, 1);
719 scriptEngine->
evaluate(code, url, 1);
QDeclarativeContextData * outerContext
The QVariant class acts like a union for the most common Qt data types.
QUrl resolvedUrl(const QUrl &)
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
The QScriptContext class represents a Qt Script function invocation.
QScriptValue newUrlContext(QDeclarativeContextData *, QObject *, const QString &)
QDeclarativeContextData * context
QHash< QString, QScriptValue > m_sharedScriptImports
QDeclarativeComponentAttached * next
QScriptValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
static QDeclarativeData * get(const QObject *object, bool create=false)
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
QIntegerForSizeof< void * >::Unsigned quintptr
#define QT_END_NAMESPACE
This macro expands to.
QString findId(int value) const
QDeclarativeEngine * engine
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
void setBaseUrl(const QUrl &)
Explicitly sets the url resolvedUrl() will use for relative references to baseUrl.
QUrl baseUrl() const
Return the base URL for this engine.
QDeclarativeContext * publicContext
QDeclarativeAbstractExpression ** m_prevExpression
#define at(className, varName)
The QByteArray class provides an array of bytes.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
QDeclarativeComponentAttached * componentAttached
QDeclarativeContextData * context
QUrl baseUrl() const
Returns the base url of the component, or the containing component if none is set.
QDeclarativeGlobalScriptClass * globalClass
QUrl resolvedUrl(const QUrl &)
Resolves the URL src relative to the URL of the containing component.
QList< QVariant > propertyValues
QDeclarativeContext * parentContext() const
Return the context's parent QDeclarativeContext, or 0 if this context has no parent or if the parent ...
QDeclarativeComponentAttached ** prev
long ASN1_INTEGER_get ASN1_INTEGER * a
QObject * contextObject() const
Return the context object, or 0 if there is no context object.
void popContext()
Pops the current execution context and restores the previous one.
static int context_count(QDeclarativeListProperty< QObject > *)
QDeclarativeContextData()
QDeclarativeAbstractExpression * expressions
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
QDeclarativeContextData * linkedContext
QDeclarativeContextData * parent
void refreshExpressions()
The QObject class is the base class of all Qt objects.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
friend class QDeclarativeContextData
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
QDeclarativeTypeNameCache * imports
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
const QScriptValue & staticGlobalObject() const
void setContextObject(QObject *)
Set the context object.
void append(const T &t)
Inserts value at the end of the list.
The QScriptEngine class provides an environment for evaluating Qt Script code.
void setParent(QDeclarativeContextData *)
QDeclarativeContextPrivate * asQDeclarativeContextPrivate()
#define QT_BEGIN_NAMESPACE
This macro expands to.
QDeclarativeAbstractExpression * m_nextExpression
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the list.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
QDeclarativeContextData * nextChild
Q_CORE_EXPORT void qWarning(const char *,...)
QDeclarativeContext * rootContext() const
Returns the engine's root context.
static const char * data(const QByteArray &arr)
QDeclarativeData * contextObjects
The QDeclarativeError class encapsulates a QML error.
QVariant contextProperty(const QString &) const
Returns the value of the name property for this context as a QVariant.
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
QDeclarativeContextData * m_context
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)
QDeclarativeIntegerCache * propertyNames
void addImportedScript(const QDeclarativeParser::Object::ScriptBlock &script)
QString findObjectId(const QObject *obj) const
void setContextProperty(const QString &, QObject *)
Set the value of the name property on this context.
static QDeclarativeContextPrivate * get(QDeclarativeContext *context)
void addObject(QObject *)
bool isValid() const
Returns whether the context is valid.
static QScriptValue newStaticScopeObject(QScriptEngine *, int propertyCount, const QString *names, const QScriptValue *values, const QScriptValue::PropertyFlags *flags)
Creates a scope object with a fixed set of undeletable properties.
int userType() const
Returns the storage type of the value stored in the variant.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
The QDeclarativeEngine class provides an environment for instantiating QML components.
QDeclarativeContextData ** prevChild
QDeclarativeContext * asQDeclarativeContext()
QObject * parent() const
Returns a pointer to the parent object.
const void * constData() const
if(void) toggleToolbarShown
virtual ~QDeclarativeContext()
Destroys the QDeclarativeContext.
void add(const QString &, int)
The QDeclarativeContext class defines a context within a QML engine.
static void exceptionToError(QScriptEngine *, QDeclarativeError &)
QVariant property(const char *name) const
Returns the value of the object's name property.
QDeclarativeEngine * engine() const
Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
QObject * toQObject(const QVariant &, bool *ok=0) const
static QObject * context_at(QDeclarativeListProperty< QObject > *, int)
void setIdProperty(int, QObject *)
QDeclarativeData ** prevContextObject
int value(const QString &)
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
QDeclarativeData * nextContextObject
QDeclarativeCompiledBindings * optimizedBindings
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
void pushScope(const QScriptValue &object)
Adds the given object to the front of this context's scope chain.
bool hasUncaughtException() const
Returns true if the last script evaluation resulted in an uncaught exception; otherwise returns false...
void warning(const QDeclarativeError &)
QList< QScriptValue > importedScripts
The QScriptValue class acts as a container for the Qt Script data types.
void setIdPropertyData(QDeclarativeIntegerCache *)
QDeclarativeContext(QDeclarativeEngine *parent, QObject *objParent=0)
Create a new QDeclarativeContext as a child of engine's root context, and the QObject parent...
QDeclarativeContextPrivate()
QDeclarativeGuardedContextData * contextGuards
static QScriptContext * pushCleanContext(QScriptEngine *)
Enters a new execution context and returns the associated QScriptContext object.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QList class is a template class that provides lists.
QDeclarativeContextScriptClass * contextClass
QDeclarativeContextData * childContexts
static QDeclarativeContextData * get(QDeclarativeContext *context)