OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / languageutils / fakemetaobject.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #include "fakemetaobject.h"
34
35 using namespace LanguageUtils;
36
37 FakeMetaEnum::FakeMetaEnum()
38 {}
39
40 FakeMetaEnum::FakeMetaEnum(const QString &name)
41     : m_name(name)
42 {}
43
44 QString FakeMetaEnum::name() const
45 { return m_name; }
46
47 void FakeMetaEnum::setName(const QString &name)
48 { m_name = name; }
49
50 void FakeMetaEnum::addKey(const QString &key, int value)
51 { m_keys.append(key); m_values.append(value); }
52
53 QString FakeMetaEnum::key(int index) const
54 { return m_keys.at(index); }
55
56 int FakeMetaEnum::keyCount() const
57 { return m_keys.size(); }
58
59 QStringList FakeMetaEnum::keys() const
60 { return m_keys; }
61
62 FakeMetaMethod::FakeMetaMethod(const QString &name, const QString &returnType)
63     : m_name(name)
64     , m_returnType(returnType)
65     , m_methodTy(FakeMetaMethod::Method)
66     , m_methodAccess(FakeMetaMethod::Public)
67 {}
68
69 FakeMetaMethod::FakeMetaMethod()
70     : m_methodTy(FakeMetaMethod::Method)
71     , m_methodAccess(FakeMetaMethod::Public)
72 {}
73
74 QString FakeMetaMethod::methodName() const
75 { return m_name; }
76
77 void FakeMetaMethod::setMethodName(const QString &name)
78 { m_name = name; }
79
80 void FakeMetaMethod::setReturnType(const QString &type)
81 { m_returnType = type; }
82
83 QStringList FakeMetaMethod::parameterNames() const
84 { return m_paramNames; }
85
86 QStringList FakeMetaMethod::parameterTypes() const
87 { return m_paramTypes; }
88
89 void FakeMetaMethod::addParameter(const QString &name, const QString &type)
90 { m_paramNames.append(name); m_paramTypes.append(type); }
91
92 int FakeMetaMethod::methodType() const
93 { return m_methodTy; }
94
95 void FakeMetaMethod::setMethodType(int methodType)
96 { m_methodTy = methodType; }
97
98 int FakeMetaMethod::access() const
99 { return m_methodAccess; }
100
101
102 FakeMetaProperty::FakeMetaProperty(const QString &name, const QString &type, bool isList, bool isWritable, bool isPointer)
103     : m_propertyName(name), m_type(type), m_isList(isList), m_isWritable(isWritable), m_isPointer(isPointer)
104 {}
105
106 QString FakeMetaProperty::name() const
107 { return m_propertyName; }
108
109 QString FakeMetaProperty::typeName() const
110 { return m_type; }
111
112 bool FakeMetaProperty::isList() const
113 { return m_isList; }
114
115 bool FakeMetaProperty::isWritable() const
116 { return m_isWritable; }
117
118 bool FakeMetaProperty::isPointer() const
119 { return m_isPointer; }
120
121
122 FakeMetaObject::FakeMetaObject()
123 {
124 }
125
126 QString FakeMetaObject::className() const
127 { return m_className; }
128 void FakeMetaObject::setClassName(const QString &name)
129 { m_className = name; }
130
131 void FakeMetaObject::addExport(const QString &name, const QString &package, ComponentVersion version)
132 {
133     Export exp;
134     exp.type = name;
135     exp.package = package;
136     exp.version = version;
137     exp.packageNameVersion = QString::fromLatin1("%1/%2 %3").arg(
138                 package, name,
139                 version.toString());
140     m_exports.append(exp);
141 }
142 QList<FakeMetaObject::Export> FakeMetaObject::exports() const
143 { return m_exports; }
144 FakeMetaObject::Export FakeMetaObject::exportInPackage(const QString &package) const
145 {
146     foreach (const Export &exp, m_exports) {
147         if (exp.package == package)
148             return exp;
149     }
150     return Export();
151 }
152
153 void FakeMetaObject::setSuperclassName(const QString &superclass)
154 { m_superName = superclass; }
155 QString FakeMetaObject::superclassName() const
156 { return m_superName; }
157
158 void FakeMetaObject::addEnum(const FakeMetaEnum &fakeEnum)
159 { m_enumNameToIndex.insert(fakeEnum.name(), m_enums.size()); m_enums.append(fakeEnum); }
160 int FakeMetaObject::enumeratorCount() const
161 { return m_enums.size(); }
162 int FakeMetaObject::enumeratorOffset() const
163 { return 0; }
164 FakeMetaEnum FakeMetaObject::enumerator(int index) const
165 { return m_enums.at(index); }
166 int FakeMetaObject::enumeratorIndex(const QString &name) const
167 { return m_enumNameToIndex.value(name, -1); }
168
169 void FakeMetaObject::addProperty(const FakeMetaProperty &property)
170 { m_propNameToIdx.insert(property.name(), m_props.size()); m_props.append(property); }
171 int FakeMetaObject::propertyCount() const
172 { return m_props.size(); }
173 int FakeMetaObject::propertyOffset() const
174 { return 0; }
175 FakeMetaProperty FakeMetaObject::property(int index) const
176 { return m_props.at(index); }
177 int FakeMetaObject::propertyIndex(const QString &name) const
178 { return m_propNameToIdx.value(name, -1); }
179
180 void FakeMetaObject::addMethod(const FakeMetaMethod &method)
181 { m_methods.append(method); }
182 int FakeMetaObject::methodCount() const
183 { return m_methods.size(); }
184 int FakeMetaObject::methodOffset() const
185 { return 0; }
186 FakeMetaMethod FakeMetaObject::method(int index) const
187 { return m_methods.at(index); }
188
189 QString FakeMetaObject::defaultPropertyName() const
190 { return m_defaultPropertyName; }
191 void FakeMetaObject::setDefaultPropertyName(const QString &defaultPropertyName)
192 { m_defaultPropertyName = defaultPropertyName; }
193
194 QString FakeMetaObject::attachedTypeName() const
195 { return m_attachedTypeName; }
196 void FakeMetaObject::setAttachedTypeName(const QString &name)
197 { m_attachedTypeName = name; }
198
199 bool FakeMetaObject::Export::isValid() const
200 { return !type.isEmpty(); }