Commit fadfe9c6 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Generalize EasingCurve name check to all enums.

Reviewed-by: Erik Verbruggen
parent 7476c0c0
......@@ -1370,12 +1370,12 @@
<type name="Qt.AnchorAnimation" version="4.7" extends="Qt.Animation">
<property name="targets" type="Qt.Item" isList="true"/>
<property name="duration" type="int"/>
<property name="easing" type="QEasingCurve"/>
<property name="easing" type="Qt.Easing"/>
<signal name="durationChanged">
<param type="int"/>
</signal>
<signal name="easingChanged">
<param type="QEasingCurve"/>
<param type="Qt.Easing"/>
</signal>
</type>
<type name="Qt.AnchorChanges" version="4.7" extends="QDeclarativeStateOperation">
......@@ -1457,10 +1457,6 @@
<enumerator name="Loading" value="2"/>
<enumerator name="Error" value="3"/>
</enum>
<property name="isNull" type="bool"/>
<property name="isReady" type="bool"/>
<property name="isError" type="bool"/>
<property name="isLoading" type="bool"/>
<property name="progress" type="qreal"/>
<property name="status" type="Status"/>
<property name="url" type="QUrl"/>
......@@ -1474,6 +1470,7 @@
</type>
<type name="Qt.Connections" version="4.7" extends="Qt.QtObject">
<property name="target" type="Qt.QtObject"/>
<property name="ignoreUnknownSignals" type="bool"/>
<signal name="targetChanged"/>
</type>
<type name="Qt.DoubleValidator" version="4.7" extends="QValidator">
......@@ -1555,7 +1552,7 @@
<enumerator name="SineCurve" value="43"/>
<enumerator name="CosineCurve" value="44"/>
</enum>
<property name="type" type="QDeclarativeEasingValueType.Type"/>
<property name="type" type="Type"/>
<property name="amplitude" type="qreal"/>
<property name="overshoot" type="qreal"/>
<property name="period" type="qreal"/>
......@@ -1566,7 +1563,7 @@
<enumerator name="DragOverBounds" value="1"/>
<enumerator name="DragAndOvershootBounds" value="2"/>
</enum>
<enum name="FlickDirection">
<enum name="FlickableDirection">
<enumerator name="AutoFlickDirection" value="0"/>
<enumerator name="HorizontalFlick" value="1"/>
<enumerator name="VerticalFlick" value="2"/>
......@@ -1583,8 +1580,13 @@
<property name="maximumFlickVelocity" type="qreal"/>
<property name="flickDeceleration" type="qreal"/>
<property name="moving" type="bool"/>
<property name="movingHorizontally" type="bool"/>
<property name="movingVertically" type="bool"/>
<property name="flicking" type="bool"/>
<property name="flickDirection" type="FlickDirection"/>
<property name="flickingHorizontally" type="bool"/>
<property name="flickingVertically" type="bool"/>
<property name="flickDirection" type="FlickableDirection"/>
<property name="flickableDirection" type="FlickableDirection"/>
<property name="interactive" type="bool"/>
<property name="pressDelay" type="int"/>
<property name="atXEnd" type="bool"/>
......@@ -1599,22 +1601,26 @@
<signal name="contentXChanged"/>
<signal name="contentYChanged"/>
<signal name="movingChanged"/>
<signal name="movingHorizontallyChanged"/>
<signal name="movingVerticallyChanged"/>
<signal name="flickingChanged"/>
<signal name="movementStarted"/>
<signal name="movementEnded"/>
<signal name="flickStarted"/>
<signal name="flickEnded"/>
<signal name="flickingHorizontallyChanged"/>
<signal name="flickingVerticallyChanged"/>
<signal name="horizontalVelocityChanged"/>
<signal name="verticalVelocityChanged"/>
<signal name="isAtBoundaryChanged"/>
<signal name="pageChanged"/>
<signal name="flickDirectionChanged"/>
<signal name="flickableDirectionChanged"/>
<signal name="interactiveChanged"/>
<signal name="overShootChanged"/>
<signal name="boundsBehaviorChanged"/>
<signal name="maximumFlickVelocityChanged"/>
<signal name="flickDecelerationChanged"/>
<signal name="pressDelayChanged"/>
<signal name="movementStarted"/>
<signal name="movementEnded"/>
<signal name="flickStarted"/>
<signal name="flickEnded"/>
</type>
<type name="Qt.Flipable" version="4.7" defaultProperty="data" extends="Qt.Item">
<enum name="Side">
......@@ -1865,18 +1871,30 @@
<method name="forceFocus"/>
</type>
<type name="Qt.KeyNavigation" version="4.7" extends="Qt.QtObject">
<enum name="Priority">
<enumerator name="BeforeItem" value="0"/>
<enumerator name="AfterItem" value="1"/>
</enum>
<property name="left" type="Qt.Item"/>
<property name="right" type="Qt.Item"/>
<property name="up" type="Qt.Item"/>
<property name="down" type="Qt.Item"/>
<property name="tab" type="Qt.Item"/>
<property name="backtab" type="Qt.Item"/>
<property name="priority" type="Priority"/>
<signal name="changed"/>
<signal name="priorityChanged"/>
</type>
<type name="Qt.Keys" version="4.7" extends="Qt.QtObject">
<enum name="Priority">
<enumerator name="BeforeItem" value="0"/>
<enumerator name="AfterItem" value="1"/>
</enum>
<property name="enabled" type="bool"/>
<property name="forwardTo" type="Qt.Item" isList="true"/>
<property name="priority" type="Priority"/>
<signal name="enabledChanged"/>
<signal name="priorityChanged"/>
<signal name="pressed">
<param name="event" type="QDeclarativeKeyEvent"/>
</signal>
......@@ -2126,14 +2144,8 @@
<enumerator name="Loading" value="2"/>
<enumerator name="Error" value="3"/>
</enum>
<enum name="ResizeMode">
<enumerator name="NoResize" value="0"/>
<enumerator name="SizeLoaderToItem" value="1"/>
<enumerator name="SizeItemToLoader" value="2"/>
</enum>
<property name="source" type="QUrl"/>
<property name="sourceComponent" type="Qt.Component"/>
<property name="resizeMode" type="ResizeMode"/>
<property name="item" type="QGraphicsObject"/>
<property name="status" type="Status"/>
<property name="progress" type="qreal"/>
......@@ -2141,7 +2153,7 @@
<signal name="sourceChanged"/>
<signal name="statusChanged"/>
<signal name="progressChanged"/>
<signal name="resizeModeChanged"/>
<signal name="loaded"/>
</type>
<type name="Qt.MouseArea" version="4.7" defaultProperty="data" extends="Qt.Item">
<property name="mouseX" type="qreal"/>
......@@ -2157,6 +2169,7 @@
<signal name="pressedChanged"/>
<signal name="enabledChanged"/>
<signal name="acceptedButtonsChanged"/>
<signal name="hoverEnabledChanged"/>
<signal name="positionChanged">
<param name="mouse" type="QDeclarativeMouseEvent"/>
</signal>
......@@ -2180,6 +2193,7 @@
</signal>
<signal name="entered"/>
<signal name="exited"/>
<signal name="canceled"/>
</type>
<type name="Qt.NumberAnimation" version="4.7" extends="Qt.PropertyAnimation">
<property name="from" type="qreal"/>
......@@ -2274,6 +2288,8 @@
<signal name="highlightChanged"/>
<signal name="highlightItemChanged"/>
<signal name="highlightMoveDurationChanged"/>
<method name="incrementCurrentIndex"/>
<method name="decrementCurrentIndex"/>
</type>
<type name="Qt.PauseAnimation" version="4.7" extends="Qt.Animation">
<property name="duration" type="int"/>
......@@ -2303,7 +2319,7 @@
<property name="duration" type="int"/>
<property name="from" type="QVariant"/>
<property name="to" type="QVariant"/>
<property name="easing" type="QEasingCurve"/>
<property name="easing" type="Qt.Easing"/>
<property name="target" type="Qt.QtObject"/>
<property name="property" type="string"/>
<property name="properties" type="string"/>
......@@ -2319,7 +2335,7 @@
<param type="QVariant"/>
</signal>
<signal name="easingChanged">
<param type="QEasingCurve"/>
<param type="Qt.Easing"/>
</signal>
<signal name="propertiesChanged">
<param type="string"/>
......@@ -3094,7 +3110,7 @@
<property name="contentsMargin" type="qreal"/>
</type>
<type name="Qt.widgets.QGraphicsLinearLayoutStretchItem" version="4.7" extends="Qt.QtObject"/>
<type name="org.webkit.WebView" version="1.0" defaultProperty="data" extends="QDeclarativePaintedItem">
<type name="org.webkit.WebView" version="1.0" defaultProperty="data" extends="Qt.Item">
<enum name="Status">
<enumerator name="Null" value="0"/>
<enumerator name="Ready" value="1"/>
......@@ -3121,6 +3137,8 @@
<property name="newWindowComponent" type="Qt.Component"/>
<property name="newWindowParent" type="Qt.Item"/>
<property name="renderingEnabled" type="bool"/>
<property name="contentsSize" type="QSize"/>
<property name="contentsScale" type="qreal"/>
<signal name="preferredWidthChanged"/>
<signal name="preferredHeightChanged"/>
<signal name="urlChanged"/>
......@@ -3139,6 +3157,10 @@
<signal name="newWindowComponentChanged"/>
<signal name="newWindowParentChanged"/>
<signal name="renderingEnabledChanged"/>
<signal name="contentsSizeChanged">
<param type="QSize"/>
</signal>
<signal name="contentsScaleChanged"/>
<signal name="loadStarted"/>
<signal name="loadFinished"/>
<signal name="loadFailed"/>
......
......@@ -64,13 +64,27 @@ public:
return _message;
}
virtual void visit(const NumberValue *)
virtual void visit(const NumberValue *value)
{
// ### Consider enums: elide: "ElideLeft" is valid, but currently elide is a NumberValue.
if (/*cast<StringLiteral *>(_ast)
if (const QmlEnumValue *enumValue = dynamic_cast<const QmlEnumValue *>(value)) {
if (StringLiteral *stringLiteral = cast<StringLiteral *>(_ast)) {
const QString valueName = stringLiteral->value->asString();
if (!enumValue->keys().contains(valueName)) {
_message.message = QCoreApplication::translate("QmlJS::Check", "unknown value for enum");
}
} else if (_rhsValue->asUndefinedValue()) {
_message.kind = DiagnosticMessage::Warning;
_message.message = QCoreApplication::translate("QmlJS::Check", "value might be 'undefined'");
} else if (! _rhsValue->asStringValue() && ! _rhsValue->asNumberValue()) {
_message.message = QCoreApplication::translate("QmlJS::Check", "enum value is not a string or number");
}
} else {
if (/*cast<StringLiteral *>(_ast)
||*/ _ast->kind == Node::Kind_TrueLiteral
|| _ast->kind == Node::Kind_FalseLiteral) {
_message.message = QCoreApplication::translate("QmlJS::Check", "numerical value expected");
|| _ast->kind == Node::Kind_FalseLiteral) {
_message.message = QCoreApplication::translate("QmlJS::Check", "numerical value expected");
}
}
}
......@@ -97,22 +111,6 @@ public:
}
}
virtual void visit(const EasingCurveNameValue *)
{
if (StringLiteral *stringLiteral = cast<StringLiteral *>(_ast)) {
const QString curveName = stringLiteral->value->asString();
if (!EasingCurveNameValue::curveNames().contains(curveName)) {
_message.message = QCoreApplication::translate("QmlJS::Check", "unknown easing-curve name");
}
} else if (_rhsValue->asUndefinedValue()) {
_message.kind = DiagnosticMessage::Warning;
_message.message = QCoreApplication::translate("QmlJS::Check", "value might be 'undefined'");
} else if (! _rhsValue->asStringValue() && ! _rhsValue->asNumberValue()) {
_message.message = QCoreApplication::translate("QmlJS::Check", "easing-curve name is not a string or number");
}
}
virtual void visit(const ColorValue *)
{
if (StringLiteral *stringLiteral = cast<StringLiteral *>(_ast)) {
......
......@@ -846,15 +846,6 @@ const Value *QmlObjectValue::propertyValue(const FakeMetaProperty &prop) const
value = engine()->colorValue();
} else if (typeName == QLatin1String("QDeclarativeAnchorLine")) {
value = engine()->anchorLineValue();
} else if (typeName == QLatin1String("QEasingCurve")) {
// ### cache
ObjectValue *object = engine()->newObject(/*prototype =*/ 0);
object->setClassName(QLatin1String("EasingCurve"));
object->setProperty("type", engine()->easingCurveNameValue());
object->setProperty("period", engine()->numberValue());
object->setProperty("amplitude", engine()->numberValue());
object->setProperty("overshoot", engine()->numberValue());
value = object;
}
// might be an enum
......@@ -1199,10 +1190,6 @@ void ValueVisitor::visit(const Reference *)
{
}
void ValueVisitor::visit(const EasingCurveNameValue *)
{
}
void ValueVisitor::visit(const ColorValue *)
{
}
......@@ -1267,11 +1254,6 @@ const Reference *Value::asReference() const
return 0;
}
const EasingCurveNameValue *Value::asEasingCurveNameValue() const
{
return 0;
}
const ColorValue *Value::asColorValue() const
{
return 0;
......@@ -1557,67 +1539,6 @@ const Value *Reference::value(Context *) const
return _engine->undefinedValue();
}
void EasingCurveNameValue::accept(ValueVisitor *visitor) const
{
visitor->visit(this);
}
QSet<QString> EasingCurveNameValue::_curveNames;
QSet<QString> EasingCurveNameValue::curveNames()
{
if (_curveNames.isEmpty()) {
_curveNames = QSet<QString>()
<< "Linear"
<< "InQuad"
<< "OutQuad"
<< "InOutQuad"
<< "OutInQuad"
<< "InCubic"
<< "OutCubic"
<< "InOutCubic"
<< "OutInCubic"
<< "InQuart"
<< "OutQuart"
<< "InOutQuart"
<< "OutInQuart"
<< "InQuint"
<< "OutQuint"
<< "InOutQuint"
<< "OutInQuint"
<< "InSine"
<< "OutSine"
<< "InOutSine"
<< "OutInSine"
<< "InExpo"
<< "OutExpo"
<< "InOutExpo"
<< "OutInExpo"
<< "InCirc"
<< "OutCirc"
<< "InOutCirc"
<< "OutInCirc"
<< "InElastic"
<< "OutElastic"
<< "InOutElastic"
<< "OutInElastic"
<< "InBack"
<< "OutBack"
<< "InOutBack"
<< "OutInBack"
<< "InBounce"
<< "OutBounce"
<< "InOutBounce"
<< "OutInBounce";
}
return _curveNames;
}
const EasingCurveNameValue *EasingCurveNameValue::asEasingCurveNameValue() const
{
return this;
}
void ColorValue::accept(ValueVisitor *visitor) const
{
visitor->visit(this);
......@@ -2337,11 +2258,6 @@ void TypeId::visit(const FunctionValue *object)
_result = QLatin1String("Function");
}
void TypeId::visit(const EasingCurveNameValue *)
{
_result = QLatin1String("string");
}
void TypeId::visit(const ColorValue *)
{
_result = QLatin1String("string");
......@@ -2412,11 +2328,6 @@ const StringValue *Engine::stringValue() const
return &_stringValue;
}
const EasingCurveNameValue *Engine::easingCurveNameValue() const
{
return &_easingCurveNameValue;
}
const ColorValue *Engine::colorValue() const
{
return &_colorValue;
......
......@@ -60,7 +60,6 @@ class StringValue;
class ObjectValue;
class FunctionValue;
class Reference;
class EasingCurveNameValue;
class ColorValue;
class AnchorLineValue;
......@@ -88,7 +87,6 @@ public:
virtual void visit(const ObjectValue *);
virtual void visit(const FunctionValue *);
virtual void visit(const Reference *);
virtual void visit(const EasingCurveNameValue *);
virtual void visit(const ColorValue *);
virtual void visit(const AnchorLineValue *);
};
......@@ -113,7 +111,6 @@ public:
virtual const ObjectValue *asObjectValue() const;
virtual const FunctionValue *asFunctionValue() const;
virtual const Reference *asReference() const;
virtual const EasingCurveNameValue *asEasingCurveNameValue() const;
virtual const ColorValue *asColorValue() const;
virtual const AnchorLineValue *asAnchorLineValue() const;
......@@ -172,12 +169,6 @@ template <> Q_INLINE_TEMPLATE const Reference *value_cast(const Value *v)
else return 0;
}
template <> Q_INLINE_TEMPLATE const EasingCurveNameValue *value_cast(const Value *v)
{
if (v) return v->asEasingCurveNameValue();
else return 0;
}
template <> Q_INLINE_TEMPLATE const ColorValue *value_cast(const Value *v)
{
if (v) return v->asColorValue();
......@@ -342,18 +333,6 @@ private:
Engine *_engine;
};
class QMLJS_EXPORT EasingCurveNameValue: public Value
{
static QSet<QString> _curveNames;
public:
static QSet<QString> curveNames();
// Value interface
virtual const EasingCurveNameValue *asEasingCurveNameValue() const;
virtual void accept(ValueVisitor *) const;
};
class QMLJS_EXPORT ColorValue: public Value
{
public:
......@@ -639,7 +618,6 @@ protected:
virtual void visit(const StringValue *);
virtual void visit(const ObjectValue *object);
virtual void visit(const FunctionValue *object);
virtual void visit(const EasingCurveNameValue *);
virtual void visit(const ColorValue *);
virtual void visit(const AnchorLineValue *);
};
......@@ -658,7 +636,6 @@ public:
const NumberValue *numberValue() const;
const BooleanValue *booleanValue() const;
const StringValue *stringValue() const;
const EasingCurveNameValue *easingCurveNameValue() const;
const ColorValue *colorValue() const;
const AnchorLineValue *anchorLineValue() const;
......@@ -744,7 +721,6 @@ private:
NumberValue _numberValue;
BooleanValue _booleanValue;
StringValue _stringValue;
EasingCurveNameValue _easingCurveNameValue;
ColorValue _colorValue;
AnchorLineValue _anchorLineValue;
QList<Value *> _registeredValues;
......
......@@ -384,8 +384,6 @@ public:
v.convert(QVariant::Double);
} else if (property->asStringValue()) {
// nothing to do
} else if (property->asEasingCurveNameValue()) {
// nothing to do
}
return v;
}
......
......@@ -268,6 +268,8 @@ int main(int argc, char *argv[])
}
cppToQml.insert("QString", "string");
cppToQml.insert("QEasingCurve", "Qt.Easing");
cppToQml.insert("QDeclarativeEasingValueType::Type", "Type");
QSet<const QMetaObject *> metas;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment