Commit 35128701 authored by Fawzi Mohamed's avatar Fawzi Mohamed
Browse files

qmljs: exposing a bit more the existence of private value types



Change-Id: I85e29b0d60234407561ecbeb2883d68c1acb71d6
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 56080c4d
......@@ -133,6 +133,10 @@ public:
}
};
} // end of anonymous namespace
namespace QmlJS {
namespace Internal {
class MetaFunction: public FunctionValue
{
FakeMetaMethod _method;
......@@ -160,9 +164,13 @@ public:
{
return false;
}
const MetaFunction *asMetaFunction() const
{
return this;
}
};
} // end of anonymous namespace
} // namespace Internal
} // namespace QmlJS
CppComponentValue::CppComponentValue(FakeMetaObject::ConstPtr metaObject, const QString &className,
const QString &packageName, const ComponentVersion &componentVersion,
......@@ -238,7 +246,7 @@ void CppComponentValue::processMembers(MemberProcessor *processor) const
signatures = new QList<const Value *>;
signatures->reserve(_metaObject->methodCount());
for (int index = 0; index < _metaObject->methodCount(); ++index)
signatures->append(new MetaFunction(_metaObject->method(index), valueOwner()));
signatures->append(new Internal::MetaFunction(_metaObject->method(index), valueOwner()));
if (!_metaSignatures.testAndSetOrdered(0, signatures)) {
delete signatures;
#if QT_VERSION >= 0x050000
......@@ -752,11 +760,46 @@ const ASTPropertyReference *Value::asAstPropertyReference() const
return 0;
}
const ASTVariableReference *Value::asAstVariableReference() const
{
return 0;
}
const Internal::QtObjectPrototypeReference *Value::asQtObjectPrototypeReference() const
{
return 0;
}
const ASTSignal *Value::asAstSignal() const
{
return 0;
}
const ASTFunctionValue *Value::asAstFunctionValue() const
{
return 0;
}
const Function *Value::asFunction() const
{
return 0;
}
const Internal::MetaFunction *Value::asMetaFunction() const
{
return 0;
}
const JSImportScope *Value::asJSImportScope() const
{
return 0;
}
const TypeScope *Value::asTypeScope() const
{
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// Values
////////////////////////////////////////////////////////////////////////////////
......@@ -1246,6 +1289,11 @@ bool Function::isVariadic() const
return _isVariadic;
}
const Function *Function::asFunction() const
{
return this;
}
////////////////////////////////////////////////////////////////////////////////
// typing environment
////////////////////////////////////////////////////////////////////////////////
......@@ -1827,6 +1875,16 @@ ASTVariableReference::~ASTVariableReference()
{
}
const ASTVariableReference *ASTVariableReference::asAstVariableReference() const
{
return this;
}
const VariableDeclaration *ASTVariableReference::ast() const
{
return _ast;
}
const Value *ASTVariableReference::value(ReferenceContext *referenceContext) const
{
// may be assigned to later
......@@ -1923,6 +1981,11 @@ bool ASTFunctionValue::isVariadic() const
return _isVariadic;
}
const ASTFunctionValue *ASTFunctionValue::asAstFunctionValue() const
{
return this;
}
bool ASTFunctionValue::getSourceLocation(QString *fileName, int *line, int *column) const
{
*fileName = _doc->fileName();
......@@ -2254,6 +2317,11 @@ void TypeScope::processMembers(MemberProcessor *processor) const
}
}
const TypeScope *TypeScope::asTypeScope() const
{
return this;
}
JSImportScope::JSImportScope(const Imports *imports, ValueOwner *valueOwner)
: ObjectValue(valueOwner)
, _imports(imports)
......@@ -2300,6 +2368,11 @@ void JSImportScope::processMembers(MemberProcessor *processor) const
}
}
const JSImportScope *JSImportScope::asJSImportScope() const
{
return this;
}
Imports::Imports(ValueOwner *valueOwner)
: _typeScope(new TypeScope(this, valueOwner))
, _jsImportScope(new JSImportScope(this, valueOwner))
......
......@@ -78,8 +78,16 @@ class CppComponentValue;
class ASTObjectValue;
class QmlEnumValue;
class QmlPrototypeReference;
class ASTVariableReference;
class ASTPropertyReference;
class ASTSignal;
class ASTFunctionValue;
class Function;
namespace Internal {
class MetaFunction;
class QtObjectPrototypeReference;
} // namespace Internal
typedef QList<const Value *> ValueList;
......@@ -136,7 +144,14 @@ public:
virtual const QmlEnumValue *asQmlEnumValue() const;
virtual const QmlPrototypeReference *asQmlPrototypeReference() const;
virtual const ASTPropertyReference *asAstPropertyReference() const;
virtual const ASTVariableReference *asAstVariableReference() const;
virtual const Internal::QtObjectPrototypeReference *asQtObjectPrototypeReference() const;
virtual const ASTSignal *asAstSignal() const;
virtual const ASTFunctionValue *asAstFunctionValue() const;
virtual const Function *asFunction() const;
virtual const Internal::MetaFunction *asMetaFunction() const;
virtual const JSImportScope *asJSImportScope() const;
virtual const TypeScope *asTypeScope() const;
virtual void accept(ValueVisitor *) const = 0;
......@@ -210,6 +225,12 @@ template <> Q_INLINE_TEMPLATE const ObjectValue *value_cast(const Value *v)
else return 0;
}
template <> Q_INLINE_TEMPLATE const ASTFunctionValue *value_cast(const Value *v)
{
if (v) return v->asAstFunctionValue();
else return 0;
}
template <> Q_INLINE_TEMPLATE const FunctionValue *value_cast(const Value *v)
{
if (v) return v->asFunctionValue();
......@@ -264,6 +285,42 @@ template <> Q_INLINE_TEMPLATE const ASTPropertyReference *value_cast(const Value
else return 0;
}
template <> Q_INLINE_TEMPLATE const Internal::QtObjectPrototypeReference *value_cast(const Value *v)
{
if (v) return v->asQtObjectPrototypeReference();
else return 0;
}
template <> Q_INLINE_TEMPLATE const ASTVariableReference *value_cast(const Value *v)
{
if (v) return v->asAstVariableReference();
else return 0;
}
template <> Q_INLINE_TEMPLATE const Function *value_cast(const Value *v)
{
if (v) return v->asFunction();
else return 0;
}
template <> Q_INLINE_TEMPLATE const Internal::MetaFunction*value_cast(const Value *v)
{
if (v) return v->asMetaFunction();
else return 0;
}
template <> Q_INLINE_TEMPLATE const JSImportScope *value_cast(const Value *v)
{
if (v) return v->asJSImportScope();
else return 0;
}
template <> Q_INLINE_TEMPLATE const TypeScope *value_cast(const Value *v)
{
if (v) return v->asTypeScope();
else return 0;
}
template <> Q_INLINE_TEMPLATE const ASTSignal *value_cast(const Value *v)
{
if (v) return v->asAstSignal();
......@@ -583,6 +640,7 @@ public:
const Value *argument(int index) const QTC_OVERRIDE;
QString argumentName(int index) const QTC_OVERRIDE;
bool isVariadic() const QTC_OVERRIDE;
const Function *asFunction() const QTC_OVERRIDE;
private:
ValueList _arguments;
......@@ -766,7 +824,8 @@ class QMLJS_EXPORT ASTVariableReference: public Reference
public:
ASTVariableReference(AST::VariableDeclaration *ast, const Document *doc, ValueOwner *valueOwner);
~ASTVariableReference();
const ASTVariableReference *asAstVariableReference() const QTC_OVERRIDE;
const AST::VariableDeclaration *ast() const;
private:
const Value *value(ReferenceContext *referenceContext) const QTC_OVERRIDE;
bool getSourceLocation(QString *fileName, int *line, int *column) const QTC_OVERRIDE;
......@@ -788,6 +847,7 @@ public:
int namedArgumentCount() const QTC_OVERRIDE;
QString argumentName(int index) const QTC_OVERRIDE;
bool isVariadic() const QTC_OVERRIDE;
const ASTFunctionValue *asAstFunctionValue() const QTC_OVERRIDE;
bool getSourceLocation(QString *fileName, int *line, int *column) const QTC_OVERRIDE;
};
......@@ -933,7 +993,7 @@ public:
const ObjectValue **foundInObject = 0,
bool examinePrototypes = true) const;
void processMembers(MemberProcessor *processor) const QTC_OVERRIDE;
const TypeScope *asTypeScope() const QTC_OVERRIDE;
private:
const Imports *_imports;
};
......@@ -947,7 +1007,7 @@ public:
const ObjectValue **foundInObject = 0,
bool examinePrototypes = true) const;
void processMembers(MemberProcessor *processor) const QTC_OVERRIDE;
const JSImportScope *asJSImportScope() const QTC_OVERRIDE;
private:
const Imports *_imports;
};
......
......@@ -44,7 +44,8 @@ using namespace QmlJS;
A ValueOwner also provides access to various default values.
*/
namespace {
namespace QmlJS {
namespace Internal {
class QtObjectPrototypeReference : public Reference
{
......@@ -52,7 +53,10 @@ public:
QtObjectPrototypeReference(ValueOwner *owner)
: Reference(owner)
{}
const QtObjectPrototypeReference *asQtObjectPrototypeReference() const QTC_OVERRIDE
{
return this;
}
private:
virtual const Value *value(ReferenceContext *referenceContext) const
{
......@@ -60,7 +64,8 @@ private:
}
};
} // end of anonymous namespace
} // end of Internal namespace
} // end of QmlJS namespace
// globally shared data
......@@ -577,7 +582,7 @@ SharedValueOwner::SharedValueOwner(SharedValueOwnerKind kind)
addFunction(_qmlMatrix4x4Object, QLatin1String("fuzzyEquals"), booleanValue(), 1, 1);
// global Qt object, in alphabetic order
_qtObject = newObject(new QtObjectPrototypeReference(this));
_qtObject = newObject(new Internal::QtObjectPrototypeReference(this));
ObjectValue *applicationObject = newObject();
applicationObject->setMember(QLatin1String("active"), booleanValue());
......
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