#include <private/qobject_p.h>
#include <private/qdeclarativerefcount_p.h>
#include <private/qdeclarativeglobal_p.h>
+#include <private/qdeclarativepool_p.h>
+#include <private/qfieldlist_p.h>
+#include <private/qdeclarativepropertycache_p.h>
+#include <private/qfastmetabuilder_p.h>
QT_BEGIN_HEADER
QT_MODULE(Declarative)
class QDeclarativePropertyCache;
-namespace QDeclarativeJS { namespace AST { class Node; } }
+namespace QDeclarativeJS { namespace AST { class Node; class StringLiteral; } }
+namespace QDeclarativeCompilerTypes { class BindingReference; class ComponentCompileState; }
/*
XXX
Location() : line(-1), column(-1) {}
int line;
int column;
+
+ inline bool operator<(const Location &other) {
+ return line < other.line ||
+ (line == other.line && column < other.column);
+ }
};
struct LocationRange
}
};
+ class Object;
class Property;
- class Object : public QDeclarativeRefCount
- {
- public:
- Object();
- virtual ~Object();
-
- // Type of the object. The integer is an index into the
- // QDeclarativeCompiledData::types array, or -1 if the object is a property
- // group.
- int type;
-
- // The fully-qualified name of this type
- QByteArray typeName;
- // The class name
- QByteArray className;
- // The id assigned to the object (if any). Set by the QDeclarativeCompiler
- QString id;
- // The id index assigned to the object (if any). Set by the QDeclarativeCompiler
- int idIndex;
- // Custom parsed data
- QByteArray custom;
- // Bit mask of the properties assigned bindings
- QByteArray bindingBitmask;
- void setBindingBit(int);
- // Returns the metaobject for this type, or 0 if not available.
- // Internally selectd between the metatype and extObject variables
- const QMetaObject *metaObject() const;
-
- // The compile time metaobject for this type
- const QMetaObject *metatype;
- // The synthesized metaobject, if QML added signals or properties to
- // this type. Otherwise null
- QAbstractDynamicMetaObject extObject;
- QByteArray metadata; // Generated by compiler
- QByteArray synthdata; // Generated by compiler
- QDeclarativePropertyCache *synthCache; // Generated by compiler
-
- Property *getDefaultProperty();
- Property *getProperty(const QByteArray &name, bool create=true);
-
- Property *defaultProperty;
- QHash<QByteArray, Property *> properties;
-
- // Output of the compilation phase (these properties continue to exist
- // in either the defaultProperty or properties members too)
- void addValueProperty(Property *);
- void addSignalProperty(Property *);
- void addAttachedProperty(Property *);
- void addGroupedProperty(Property *);
- void addValueTypeProperty(Property *);
- void addScriptStringProperty(Property *, int = 0);
- QList<Property *> valueProperties;
- QList<Property *> signalProperties;
- QList<Property *> attachedProperties;
- QList<Property *> groupedProperties;
- QList<Property *> valueTypeProperties;
- QList<QPair<Property *, int> > scriptStringProperties;
-
- // Script blocks that were nested under this object
- struct ScriptBlock {
- enum Pragma {
- None = 0x00000000,
- Shared = 0x00000001
- };
- Q_DECLARE_FLAGS(Pragmas, Pragma)
-
- QString code;
- QString file;
- Pragmas pragmas;
- };
-
- // The bytes to cast instances by to get to the QDeclarativeParserStatus
- // interface. -1 indicates the type doesn't support this interface.
- // Set by the QDeclarativeCompiler.
- int parserStatusCast;
-
- LocationSpan location;
-
- struct DynamicProperty {
- DynamicProperty();
- DynamicProperty(const DynamicProperty &);
-
- enum Type { Variant, Int, Bool, Real, String, Url, Color, Time, Date, DateTime, Alias, Custom, CustomList };
-
- bool isDefaultProperty;
- Type type;
- QByteArray customType;
- QByteArray name;
- QDeclarativeParser::Property *defaultValue;
- LocationSpan location;
- };
- struct DynamicSignal {
- DynamicSignal();
- DynamicSignal(const DynamicSignal &);
-
- QByteArray name;
- QList<QByteArray> parameterTypes;
- QList<QByteArray> parameterNames;
- };
- struct DynamicSlot {
- DynamicSlot();
- DynamicSlot(const DynamicSlot &);
-
- QByteArray name;
- QString body;
- QList<QByteArray> parameterNames;
- LocationSpan location;
- };
-
- // The list of dynamic properties
- QList<DynamicProperty> dynamicProperties;
- // The list of dynamic signals
- QList<DynamicSignal> dynamicSignals;
- // The list of dynamic slots
- QList<DynamicSlot> dynamicSlots;
- };
-
class Q_DECLARATIVE_EXPORT Variant
{
public:
Variant();
Variant(const Variant &);
- Variant(bool);
- Variant(double, const QString &asWritten=QString());
- Variant(const QString &);
- Variant(const QString &, QDeclarativeJS::AST::Node *);
+ explicit Variant(bool);
+ explicit Variant(double, const QStringRef &asWritten = QStringRef());
+ explicit Variant(QDeclarativeJS::AST::StringLiteral *);
+ explicit Variant(const QStringRef &asWritten, QDeclarativeJS::AST::Node *);
Variant &operator=(const Variant &);
Type type() const;
union {
bool b;
double d;
+ QDeclarativeJS::AST::StringLiteral *l;
QDeclarativeJS::AST::Node *n;
};
- QString s;
+ QStringRef asWritten;
};
- class Value : public QDeclarativeRefCount
+ class Value : public QDeclarativePool::POD
{
public:
Value();
- virtual ~Value();
enum Type {
// The type of this value assignment is not yet known
Object *object;
LocationSpan location;
+
+ // Used by compiler
+ QDeclarativeCompilerTypes::BindingReference *bindingReference;
+ int signalExpressionContextStack;
+
+ // Used in Property::ValueList lists
+ Value *nextValue;
};
- class Property : public QDeclarativeRefCount
+ class Property : public QDeclarativePool::POD
{
public:
Property();
- Property(const QByteArray &n);
- virtual ~Property();
// The Object to which this property is attached
Object *parent;
int type;
// The metaobject index of this property, or -1 if unknown.
int index;
+ // The core data in the case of a regular property.
+ // XXX This has to be a value now as the synthCache may change during
+ // compilation which invalidates pointers. We should fix this.
+ QDeclarativePropertyCache::Data core;
// Returns true if this is an empty property - both value and values
// are unset.
bool isEmpty() const;
+
+ typedef QFieldList<Value, &Value::nextValue> ValueList;
// The list of values assigned to this property. Content in values
// and value are mutually exclusive
- QList<Value *> values;
+ ValueList values;
// The list of values assigned to this property using the "on" syntax
- QList<Value *> onValues;
+ ValueList onValues;
// The accessed property. This is used to represent dot properties.
// Content in value and values are mutually exclusive.
Object *value;
// The property name
- QByteArray name;
+ QStringRef name() const { return _name; }
+ void setName(const QString &n) { _name = QStringRef(pool()->NewString(n)); }
// True if this property was accessed as the default property.
bool isDefault;
// True if the setting of this property will be deferred. Set by the
// QDeclarativeCompiler
bool isAlias;
+ // Used for scriptStringProperties
+ int scriptStringScope;
+
LocationSpan location;
LocationRange listValueRange;
+
+ // Used in Object::MainPropertyList
+ Property *nextMainProperty;
+
+ // Used in Object::PropertyList lists
+ Property *nextProperty;
+
+ private:
+ friend class Object;
+ QStringRef _name;
};
+
+ class Object : public QDeclarativePool::Class
+ {
+ public:
+ Object();
+ virtual ~Object();
+
+ // Type of the object. The integer is an index into the
+ // QDeclarativeCompiledData::types array, or -1 if the object is a property
+ // group.
+ int type;
+
+ // The fully-qualified name of this type
+ QByteArray typeName;
+ // The id assigned to the object (if any). Set by the QDeclarativeCompiler
+ QString id;
+ // The id index assigned to the object (if any). Set by the QDeclarativeCompiler
+ int idIndex;
+ // Custom parsed data
+ QByteArray custom;
+ // Bit mask of the properties assigned bindings
+ QByteArray bindingBitmask;
+ void setBindingBit(int);
+ // Returns the metaobject for this type, or 0 if not available.
+ // Internally selectd between the metatype and extObject variables
+ const QMetaObject *metaObject() const;
+
+ // The compile time metaobject for this type
+ const QMetaObject *metatype;
+ // The synthesized metaobject, if QML added signals or properties to
+ // this type. Otherwise null
+ QAbstractDynamicMetaObject extObject;
+ QByteArray metadata; // Generated by compiler
+ QByteArray synthdata; // Generated by compiler
+ QDeclarativePropertyCache *synthCache; // Generated by compiler
+
+ Property *getDefaultProperty();
+ // name ptr must be guarenteed to remain valid
+ Property *getProperty(const QStringRef &name, bool create=true);
+ Property *getProperty(const QString &name, bool create=true);
+
+ Property *defaultProperty;
+
+ typedef QFieldList<Property, &Property::nextMainProperty> MainPropertyList;
+ MainPropertyList properties;
+
+ // Output of the compilation phase (these properties continue to exist
+ // in either the defaultProperty or properties members too)
+ void addValueProperty(Property *);
+ void addSignalProperty(Property *);
+ void addAttachedProperty(Property *);
+ void addGroupedProperty(Property *);
+ void addValueTypeProperty(Property *);
+ void addScriptStringProperty(Property *);
+
+ typedef QFieldList<Property, &Property::nextProperty> PropertyList;
+ PropertyList valueProperties;
+ PropertyList signalProperties;
+ PropertyList attachedProperties;
+ PropertyList groupedProperties;
+ PropertyList valueTypeProperties;
+ PropertyList scriptStringProperties;
+
+ // Script blocks that were nested under this object
+ struct ScriptBlock {
+ enum Pragma {
+ None = 0x00000000,
+ Shared = 0x00000001
+ };
+ Q_DECLARE_FLAGS(Pragmas, Pragma)
+
+ QString code;
+ QString file;
+ Pragmas pragmas;
+ };
+
+ // The bytes to cast instances by to get to the QDeclarativeParserStatus
+ // interface. -1 indicates the type doesn't support this interface.
+ // Set by the QDeclarativeCompiler.
+ int parserStatusCast;
+
+ LocationSpan location;
+
+ struct DynamicProperty {
+ DynamicProperty();
+ DynamicProperty(const DynamicProperty &);
+
+ enum Type { Variant, Int, Bool, Real, String, Url, Color, Time, Date, DateTime, Alias, Custom, CustomList };
+
+ bool isDefaultProperty;
+ Type type;
+ QByteArray customType;
+ QByteArray name;
+ QDeclarativeParser::Property *defaultValue;
+ LocationSpan location;
+
+ // Used by the compiler
+ QByteArray resolvedCustomTypeName;
+ QFastMetaBuilder::StringRef typeRef;
+ QFastMetaBuilder::StringRef nameRef;
+ QFastMetaBuilder::StringRef changedSignatureRef;
+ };
+ struct DynamicSignal {
+ DynamicSignal();
+ DynamicSignal(const DynamicSignal &);
+
+ QByteArray name;
+ QList<QByteArray> parameterTypes;
+ QList<QByteArray> parameterNames;
+
+ int parameterTypesLength() const;
+ int parameterNamesLength() const;
+
+ // Used by the compiler
+ QFastMetaBuilder::StringRef signatureRef;
+ QFastMetaBuilder::StringRef parameterNamesRef;
+ };
+ struct DynamicSlot {
+ DynamicSlot();
+ DynamicSlot(const DynamicSlot &);
+
+ QByteArray name;
+ QString body;
+ QList<QByteArray> parameterNames;
+ LocationSpan location;
+
+ int parameterNamesLength() const;
+
+ // Used by the compiler
+ QFastMetaBuilder::StringRef signatureRef;
+ QFastMetaBuilder::StringRef parameterNamesRef;
+ };
+
+ // The list of dynamic properties
+ QList<DynamicProperty> dynamicProperties;
+ // The list of dynamic signals
+ QList<DynamicSignal> dynamicSignals;
+ // The list of dynamic slots
+ QList<DynamicSlot> dynamicSlots;
+
+ // Used by compiler
+ QDeclarativeCompilerTypes::ComponentCompileState *componentCompileState;
+
+ // Used by ComponentCompileState::AliasingObjectsList
+ Object *nextAliasingObject;
+ // Used by ComponentComppileState::IdList
+ Object *nextIdObject;
+ };
+
}
Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeParser::Object::ScriptBlock::Pragmas);