2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-01 12:11:02 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-07-01 12:11:02 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-01 12:11:02 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-07-01 12:11:02 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-07-01 12:11:02 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-07-01 12:11:02 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-07-01 12:11:02 +02:00
|
|
|
|
|
|
|
|
#ifndef QMLJS_VALUEOWNER_H
|
|
|
|
|
#define QMLJS_VALUEOWNER_H
|
|
|
|
|
|
|
|
|
|
#include "qmljs_global.h"
|
|
|
|
|
#include "qmljsinterpreter.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QList>
|
2011-07-01 12:11:02 +02:00
|
|
|
|
|
|
|
|
namespace QmlJS {
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Forward declarations
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
class Value;
|
|
|
|
|
class NullValue;
|
|
|
|
|
class UndefinedValue;
|
2011-10-10 12:53:28 +02:00
|
|
|
class UnknownValue;
|
2011-07-01 12:11:02 +02:00
|
|
|
class NumberValue;
|
|
|
|
|
class IntValue;
|
|
|
|
|
class RealValue;
|
|
|
|
|
class BooleanValue;
|
|
|
|
|
class StringValue;
|
|
|
|
|
class UrlValue;
|
|
|
|
|
class ObjectValue;
|
|
|
|
|
class FunctionValue;
|
|
|
|
|
class Reference;
|
|
|
|
|
class ColorValue;
|
|
|
|
|
class AnchorLineValue;
|
|
|
|
|
class Imports;
|
|
|
|
|
class TypeScope;
|
|
|
|
|
class JSImportScope;
|
|
|
|
|
class Function;
|
2011-11-21 14:51:03 +01:00
|
|
|
class SharedValueOwner;
|
2011-07-01 12:11:02 +02:00
|
|
|
|
|
|
|
|
class QMLJS_EXPORT ValueOwner
|
|
|
|
|
{
|
|
|
|
|
Q_DISABLE_COPY(ValueOwner)
|
|
|
|
|
|
|
|
|
|
public:
|
2011-11-21 14:51:03 +01:00
|
|
|
ValueOwner(const SharedValueOwner *shared = 0);
|
2011-07-01 12:11:02 +02:00
|
|
|
~ValueOwner();
|
|
|
|
|
|
|
|
|
|
const NullValue *nullValue() const;
|
|
|
|
|
const UndefinedValue *undefinedValue() const;
|
2011-10-10 12:53:28 +02:00
|
|
|
const UnknownValue *unknownValue() const;
|
2011-07-01 12:11:02 +02:00
|
|
|
const NumberValue *numberValue() const;
|
|
|
|
|
const RealValue *realValue() const;
|
|
|
|
|
const IntValue *intValue() const;
|
|
|
|
|
const BooleanValue *booleanValue() const;
|
|
|
|
|
const StringValue *stringValue() const;
|
|
|
|
|
const UrlValue *urlValue() const;
|
|
|
|
|
const ColorValue *colorValue() const;
|
|
|
|
|
const AnchorLineValue *anchorLineValue() const;
|
|
|
|
|
|
2011-11-21 14:51:03 +01:00
|
|
|
ObjectValue *newObject(const Value *prototype);
|
2011-07-01 12:11:02 +02:00
|
|
|
ObjectValue *newObject();
|
|
|
|
|
|
|
|
|
|
// QML objects
|
|
|
|
|
const ObjectValue *qmlKeysObject();
|
|
|
|
|
const ObjectValue *qmlFontObject();
|
|
|
|
|
const ObjectValue *qmlPointObject();
|
|
|
|
|
const ObjectValue *qmlSizeObject();
|
|
|
|
|
const ObjectValue *qmlRectObject();
|
|
|
|
|
const ObjectValue *qmlVector3DObject();
|
|
|
|
|
|
2011-09-13 14:29:47 +02:00
|
|
|
// converts builtin types, such as int, string to a Value
|
2011-07-01 12:11:02 +02:00
|
|
|
const Value *defaultValueForBuiltinType(const QString &typeName) const;
|
|
|
|
|
|
|
|
|
|
// global object
|
2011-11-21 14:51:03 +01:00
|
|
|
const ObjectValue *globalObject() const;
|
2011-07-01 12:11:02 +02:00
|
|
|
const ObjectValue *mathObject() const;
|
|
|
|
|
const ObjectValue *qtObject() const;
|
|
|
|
|
|
|
|
|
|
// prototypes
|
2011-11-21 14:51:03 +01:00
|
|
|
const ObjectValue *objectPrototype() const;
|
|
|
|
|
const ObjectValue *functionPrototype() const;
|
|
|
|
|
const ObjectValue *numberPrototype() const;
|
|
|
|
|
const ObjectValue *booleanPrototype() const;
|
|
|
|
|
const ObjectValue *stringPrototype() const;
|
|
|
|
|
const ObjectValue *arrayPrototype() const;
|
|
|
|
|
const ObjectValue *datePrototype() const;
|
|
|
|
|
const ObjectValue *regexpPrototype() const;
|
2011-07-01 12:11:02 +02:00
|
|
|
|
|
|
|
|
// ctors
|
|
|
|
|
const FunctionValue *objectCtor() const;
|
|
|
|
|
const FunctionValue *functionCtor() const;
|
|
|
|
|
const FunctionValue *arrayCtor() const;
|
|
|
|
|
const FunctionValue *stringCtor() const;
|
|
|
|
|
const FunctionValue *booleanCtor() const;
|
|
|
|
|
const FunctionValue *numberCtor() const;
|
|
|
|
|
const FunctionValue *dateCtor() const;
|
|
|
|
|
const FunctionValue *regexpCtor() const;
|
|
|
|
|
|
|
|
|
|
// operators
|
|
|
|
|
const Value *convertToBoolean(const Value *value);
|
|
|
|
|
const Value *convertToNumber(const Value *value);
|
|
|
|
|
const Value *convertToString(const Value *value);
|
|
|
|
|
const Value *convertToObject(const Value *value);
|
|
|
|
|
QString typeId(const Value *value);
|
|
|
|
|
|
|
|
|
|
// typing:
|
|
|
|
|
CppQmlTypes &cppQmlTypes()
|
|
|
|
|
{ return _cppQmlTypes; }
|
|
|
|
|
const CppQmlTypes &cppQmlTypes() const
|
|
|
|
|
{ return _cppQmlTypes; }
|
|
|
|
|
|
|
|
|
|
void registerValue(Value *value); // internal
|
|
|
|
|
|
2011-11-21 14:51:03 +01:00
|
|
|
protected:
|
2011-11-16 09:56:53 +01:00
|
|
|
Function *addFunction(ObjectValue *object, const QString &name, const Value *result,
|
|
|
|
|
int argumentCount = 0, int optionalCount = 0, bool variadic = false);
|
|
|
|
|
Function *addFunction(ObjectValue *object, const QString &name,
|
|
|
|
|
int argumentCount = 0, int optionalCount = 0, bool variadic = false);
|
2011-07-01 12:11:02 +02:00
|
|
|
|
|
|
|
|
QList<Value *> _registeredValues;
|
2011-11-21 14:51:03 +01:00
|
|
|
QMutex _mutex;
|
2011-07-01 12:11:02 +02:00
|
|
|
|
|
|
|
|
ConvertToNumber _convertToNumber;
|
|
|
|
|
ConvertToString _convertToString;
|
|
|
|
|
ConvertToObject _convertToObject;
|
|
|
|
|
TypeId _typeId;
|
|
|
|
|
CppQmlTypes _cppQmlTypes;
|
|
|
|
|
|
2011-11-21 14:51:03 +01:00
|
|
|
const SharedValueOwner *_shared;
|
2011-07-01 12:11:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlJS
|
|
|
|
|
|
|
|
|
|
#endif // QMLJS_VALUEOWNER_H
|