Differential D24817 Diff 68400 src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QModelIndex.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QModelIndex.cpp
- This file was added.
1 | #include <QtScript/QScriptEngine> | ||||
---|---|---|---|---|---|
2 | #include <QtScript/QScriptContext> | ||||
3 | #include <QtScript/QScriptValue> | ||||
4 | #include <QtCore/QStringList> | ||||
5 | #include <QtCore/QDebug> | ||||
6 | #include <qmetaobject.h> | ||||
7 | #include <__package_shared.h> | ||||
8 | | ||||
9 | #include <qabstractitemmodel.h> | ||||
10 | #include <QVariant> | ||||
11 | #include <qabstractitemmodel.h> | ||||
12 | | ||||
13 | static const char * const qtscript_QModelIndex_function_names[] = { | ||||
14 | "QModelIndex" | ||||
15 | // static | ||||
16 | // prototype | ||||
17 | , "child" | ||||
18 | , "column" | ||||
19 | , "data" | ||||
20 | , "flags" | ||||
21 | , "internalId" | ||||
22 | , "internalPointer" | ||||
23 | , "isValid" | ||||
24 | , "model" | ||||
25 | , "equals" | ||||
26 | , "operator_less" | ||||
27 | , "parent" | ||||
28 | , "row" | ||||
29 | , "sibling" | ||||
30 | , "toString" | ||||
31 | }; | ||||
32 | | ||||
33 | static const char * const qtscript_QModelIndex_function_signatures[] = { | ||||
34 | "" | ||||
35 | // static | ||||
36 | // prototype | ||||
37 | , "int row, int column" | ||||
38 | , "" | ||||
39 | , "int role" | ||||
40 | , "" | ||||
41 | , "" | ||||
42 | , "" | ||||
43 | , "" | ||||
44 | , "" | ||||
45 | , "QModelIndex other" | ||||
46 | , "QModelIndex other" | ||||
47 | , "" | ||||
48 | , "" | ||||
49 | , "int row, int column" | ||||
50 | "" | ||||
51 | }; | ||||
52 | | ||||
53 | static const int qtscript_QModelIndex_function_lengths[] = { | ||||
54 | 0 | ||||
55 | // static | ||||
56 | // prototype | ||||
57 | , 2 | ||||
58 | , 0 | ||||
59 | , 1 | ||||
60 | , 0 | ||||
61 | , 0 | ||||
62 | , 0 | ||||
63 | , 0 | ||||
64 | , 0 | ||||
65 | , 1 | ||||
66 | , 1 | ||||
67 | , 0 | ||||
68 | , 0 | ||||
69 | , 2 | ||||
70 | , 0 | ||||
71 | }; | ||||
72 | | ||||
73 | static QScriptValue qtscript_QModelIndex_throw_ambiguity_error_helper( | ||||
74 | QScriptContext *context, const char *functionName, const char *signatures) | ||||
75 | { | ||||
76 | QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\n')); | ||||
77 | QStringList fullSignatures; | ||||
78 | for (int i = 0; i < lines.size(); ++i) | ||||
79 | fullSignatures.append(QString::fromLatin1("%0(%1)").arg(functionName).arg(lines.at(i))); | ||||
80 | return context->throwError(QString::fromLatin1("QModelIndex::%0(): could not find a function match; candidates are:\n%1") | ||||
81 | .arg(functionName).arg(fullSignatures.join(QLatin1String("\n")))); | ||||
82 | } | ||||
83 | | ||||
84 | Q_DECLARE_METATYPE(QModelIndex*) | ||||
85 | Q_DECLARE_METATYPE(QFlags<Qt::ItemFlag>) | ||||
86 | Q_DECLARE_METATYPE(quintptr) | ||||
87 | Q_DECLARE_METATYPE(const QAbstractItemModel*) | ||||
88 | | ||||
89 | // | ||||
90 | // QModelIndex | ||||
91 | // | ||||
92 | | ||||
93 | static QScriptValue qtscript_QModelIndex_prototype_call(QScriptContext *context, QScriptEngine *) | ||||
94 | { | ||||
95 | #if QT_VERSION > 0x040400 | ||||
96 | Q_ASSERT(context->callee().isFunction()); | ||||
97 | uint _id = context->callee().data().toUInt32(); | ||||
98 | #else | ||||
99 | uint _id; | ||||
100 | if (context->callee().isFunction()) | ||||
101 | _id = context->callee().data().toUInt32(); | ||||
102 | else | ||||
103 | _id = 0xBABE0000 + 13; | ||||
104 | #endif | ||||
105 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
106 | _id &= 0x0000FFFF; | ||||
107 | QModelIndex* _q_self = qscriptvalue_cast<QModelIndex*>(context->thisObject()); | ||||
108 | if (!_q_self) { | ||||
109 | return context->throwError(QScriptContext::TypeError, | ||||
110 | QString::fromLatin1("QModelIndex.%0(): this object is not a QModelIndex") | ||||
111 | .arg(qtscript_QModelIndex_function_names[_id+1])); | ||||
112 | } | ||||
113 | | ||||
114 | switch (_id) { | ||||
115 | case 0: | ||||
116 | if (context->argumentCount() == 2) { | ||||
117 | int _q_arg0 = context->argument(0).toInt32(); | ||||
118 | int _q_arg1 = context->argument(1).toInt32(); | ||||
119 | QModelIndex _q_result = _q_self->child(_q_arg0, _q_arg1); | ||||
120 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
121 | } | ||||
122 | break; | ||||
123 | | ||||
124 | case 1: | ||||
125 | if (context->argumentCount() == 0) { | ||||
126 | int _q_result = _q_self->column(); | ||||
127 | return QScriptValue(context->engine(), _q_result); | ||||
128 | } | ||||
129 | break; | ||||
130 | | ||||
131 | case 2: | ||||
132 | if (context->argumentCount() == 0) { | ||||
133 | QVariant _q_result = _q_self->data(); | ||||
134 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
135 | } | ||||
136 | if (context->argumentCount() == 1) { | ||||
137 | int _q_arg0 = context->argument(0).toInt32(); | ||||
138 | QVariant _q_result = _q_self->data(_q_arg0); | ||||
139 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
140 | } | ||||
141 | break; | ||||
142 | | ||||
143 | case 3: | ||||
144 | if (context->argumentCount() == 0) { | ||||
145 | QFlags<Qt::ItemFlag> _q_result = _q_self->flags(); | ||||
146 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
147 | } | ||||
148 | break; | ||||
149 | | ||||
150 | case 4: | ||||
151 | if (context->argumentCount() == 0) { | ||||
152 | quintptr _q_result = _q_self->internalId(); | ||||
153 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
154 | } | ||||
155 | break; | ||||
156 | | ||||
157 | case 5: | ||||
158 | if (context->argumentCount() == 0) { | ||||
159 | void* _q_result = _q_self->internalPointer(); | ||||
160 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
161 | } | ||||
162 | break; | ||||
163 | | ||||
164 | case 6: | ||||
165 | if (context->argumentCount() == 0) { | ||||
166 | bool _q_result = _q_self->isValid(); | ||||
167 | return QScriptValue(context->engine(), _q_result); | ||||
168 | } | ||||
169 | break; | ||||
170 | | ||||
171 | case 7: | ||||
172 | if (context->argumentCount() == 0) { | ||||
173 | const QAbstractItemModel* _q_result = const_cast<const QAbstractItemModel*>(_q_self->model()); | ||||
174 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
175 | } | ||||
176 | break; | ||||
177 | | ||||
178 | case 8: | ||||
179 | if (context->argumentCount() == 1) { | ||||
180 | QModelIndex _q_arg0 = qscriptvalue_cast<QModelIndex>(context->argument(0)); | ||||
181 | bool _q_result = _q_self->operator==(_q_arg0); | ||||
182 | return QScriptValue(context->engine(), _q_result); | ||||
183 | } | ||||
184 | break; | ||||
185 | | ||||
186 | case 9: | ||||
187 | if (context->argumentCount() == 1) { | ||||
188 | QModelIndex _q_arg0 = qscriptvalue_cast<QModelIndex>(context->argument(0)); | ||||
189 | bool _q_result = _q_self->operator<(_q_arg0); | ||||
190 | return QScriptValue(context->engine(), _q_result); | ||||
191 | } | ||||
192 | break; | ||||
193 | | ||||
194 | case 10: | ||||
195 | if (context->argumentCount() == 0) { | ||||
196 | QModelIndex _q_result = _q_self->parent(); | ||||
197 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
198 | } | ||||
199 | break; | ||||
200 | | ||||
201 | case 11: | ||||
202 | if (context->argumentCount() == 0) { | ||||
203 | int _q_result = _q_self->row(); | ||||
204 | return QScriptValue(context->engine(), _q_result); | ||||
205 | } | ||||
206 | break; | ||||
207 | | ||||
208 | case 12: | ||||
209 | if (context->argumentCount() == 2) { | ||||
210 | int _q_arg0 = context->argument(0).toInt32(); | ||||
211 | int _q_arg1 = context->argument(1).toInt32(); | ||||
212 | QModelIndex _q_result = _q_self->sibling(_q_arg0, _q_arg1); | ||||
213 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
214 | } | ||||
215 | break; | ||||
216 | | ||||
217 | case 13: { | ||||
218 | QString result; | ||||
219 | QDebug d(&result); | ||||
220 | d << *_q_self; | ||||
221 | return QScriptValue(context->engine(), result); | ||||
222 | } | ||||
223 | | ||||
224 | default: | ||||
225 | Q_ASSERT(false); | ||||
226 | } | ||||
227 | return qtscript_QModelIndex_throw_ambiguity_error_helper(context, | ||||
228 | qtscript_QModelIndex_function_names[_id+1], | ||||
229 | qtscript_QModelIndex_function_signatures[_id+1]); | ||||
230 | } | ||||
231 | | ||||
232 | static QScriptValue qtscript_QModelIndex_static_call(QScriptContext *context, QScriptEngine *) | ||||
233 | { | ||||
234 | uint _id = context->callee().data().toUInt32(); | ||||
235 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
236 | _id &= 0x0000FFFF; | ||||
237 | switch (_id) { | ||||
238 | case 0: | ||||
239 | if (context->thisObject().strictlyEquals(context->engine()->globalObject())) { | ||||
240 | return context->throwError(QString::fromLatin1("QModelIndex(): Did you forget to construct with 'new'?")); | ||||
241 | } | ||||
242 | if (context->argumentCount() == 0) { | ||||
243 | QModelIndex _q_cpp_result; | ||||
244 | QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result)); | ||||
245 | return _q_result; | ||||
246 | } | ||||
247 | break; | ||||
248 | | ||||
249 | default: | ||||
250 | Q_ASSERT(false); | ||||
251 | } | ||||
252 | return qtscript_QModelIndex_throw_ambiguity_error_helper(context, | ||||
253 | qtscript_QModelIndex_function_names[_id], | ||||
254 | qtscript_QModelIndex_function_signatures[_id]); | ||||
255 | } | ||||
256 | | ||||
257 | QScriptValue qtscript_create_QModelIndex_class(QScriptEngine *engine) | ||||
258 | { | ||||
259 | engine->setDefaultPrototype(qMetaTypeId<QModelIndex*>(), QScriptValue()); | ||||
260 | QScriptValue proto = engine->newVariant(qVariantFromValue((QModelIndex*)0)); | ||||
261 | for (int i = 0; i < 14; ++i) { | ||||
262 | QScriptValue fun = engine->newFunction(qtscript_QModelIndex_prototype_call, qtscript_QModelIndex_function_lengths[i+1]); | ||||
263 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i))); | ||||
264 | proto.setProperty(QString::fromLatin1(qtscript_QModelIndex_function_names[i+1]), | ||||
265 | fun, QScriptValue::SkipInEnumeration); | ||||
266 | } | ||||
267 | | ||||
268 | engine->setDefaultPrototype(qMetaTypeId<QModelIndex>(), proto); | ||||
269 | engine->setDefaultPrototype(qMetaTypeId<QModelIndex*>(), proto); | ||||
270 | | ||||
271 | QScriptValue ctor = engine->newFunction(qtscript_QModelIndex_static_call, proto, qtscript_QModelIndex_function_lengths[0]); | ||||
272 | ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0))); | ||||
273 | | ||||
274 | return ctor; | ||||
275 | } |