Differential D24817 Diff 68400 src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QObject.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QObject.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 <qobject.h> | ||||
10 | #include <QVarLengthArray> | ||||
11 | #include <QVariant> | ||||
12 | #include <qbytearray.h> | ||||
13 | #include <qcoreevent.h> | ||||
14 | #include <qlist.h> | ||||
15 | #include <qobject.h> | ||||
16 | | ||||
17 | #include "qtscriptshell_QObject.h" | ||||
18 | | ||||
19 | static const char * const qtscript_QObject_function_names[] = { | ||||
20 | "QObject" | ||||
21 | // static | ||||
22 | // prototype | ||||
23 | , "blockSignals" | ||||
24 | , "children" | ||||
25 | , "dumpObjectInfo" | ||||
26 | , "dumpObjectTree" | ||||
27 | , "dynamicPropertyNames" | ||||
28 | , "event" | ||||
29 | , "eventFilter" | ||||
30 | , "inherits" | ||||
31 | , "installEventFilter" | ||||
32 | , "isWidgetType" | ||||
33 | , "isWindowType" | ||||
34 | , "killTimer" | ||||
35 | , "parent" | ||||
36 | , "property" | ||||
37 | , "removeEventFilter" | ||||
38 | , "setParent" | ||||
39 | , "setProperty" | ||||
40 | , "signalsBlocked" | ||||
41 | , "startTimer" | ||||
42 | , "toString" | ||||
43 | }; | ||||
44 | | ||||
45 | static const char * const qtscript_QObject_function_signatures[] = { | ||||
46 | "QObject parent" | ||||
47 | // static | ||||
48 | // prototype | ||||
49 | , "bool b" | ||||
50 | , "" | ||||
51 | , "" | ||||
52 | , "" | ||||
53 | , "" | ||||
54 | , "QEvent arg__1" | ||||
55 | , "QObject arg__1, QEvent arg__2" | ||||
56 | , "char classname" | ||||
57 | , "QObject arg__1" | ||||
58 | , "" | ||||
59 | , "" | ||||
60 | , "int id" | ||||
61 | , "" | ||||
62 | , "char name" | ||||
63 | , "QObject arg__1" | ||||
64 | , "QObject arg__1" | ||||
65 | , "char name, Object value" | ||||
66 | , "" | ||||
67 | , "int interval, TimerType timerType" | ||||
68 | "" | ||||
69 | }; | ||||
70 | | ||||
71 | static const int qtscript_QObject_function_lengths[] = { | ||||
72 | 1 | ||||
73 | // static | ||||
74 | // prototype | ||||
75 | , 1 | ||||
76 | , 0 | ||||
77 | , 0 | ||||
78 | , 0 | ||||
79 | , 0 | ||||
80 | , 1 | ||||
81 | , 2 | ||||
82 | , 1 | ||||
83 | , 1 | ||||
84 | , 0 | ||||
85 | , 0 | ||||
86 | , 1 | ||||
87 | , 0 | ||||
88 | , 1 | ||||
89 | , 1 | ||||
90 | , 1 | ||||
91 | , 2 | ||||
92 | , 0 | ||||
93 | , 2 | ||||
94 | , 0 | ||||
95 | }; | ||||
96 | | ||||
97 | static QScriptValue qtscript_QObject_throw_ambiguity_error_helper( | ||||
98 | QScriptContext *context, const char *functionName, const char *signatures) | ||||
99 | { | ||||
100 | QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\n')); | ||||
101 | QStringList fullSignatures; | ||||
102 | for (int i = 0; i < lines.size(); ++i) | ||||
103 | fullSignatures.append(QString::fromLatin1("%0(%1)").arg(functionName).arg(lines.at(i))); | ||||
104 | return context->throwError(QString::fromLatin1("QObject::%0(): could not find a function match; candidates are:\n%1") | ||||
105 | .arg(functionName).arg(fullSignatures.join(QLatin1String("\n")))); | ||||
106 | } | ||||
107 | | ||||
108 | Q_DECLARE_METATYPE(QtScriptShell_QObject*) | ||||
109 | Q_DECLARE_METATYPE(QList<QObject* >) | ||||
110 | Q_DECLARE_METATYPE(QList<QByteArray >) | ||||
111 | Q_DECLARE_METATYPE(QEvent*) | ||||
112 | Q_DECLARE_METATYPE(Qt::TimerType) | ||||
113 | | ||||
114 | // | ||||
115 | // QObject | ||||
116 | // | ||||
117 | | ||||
118 | static QScriptValue qtscript_QObject_prototype_call(QScriptContext *context, QScriptEngine *) | ||||
119 | { | ||||
120 | #if QT_VERSION > 0x040400 | ||||
121 | Q_ASSERT(context->callee().isFunction()); | ||||
122 | uint _id = context->callee().data().toUInt32(); | ||||
123 | #else | ||||
124 | uint _id; | ||||
125 | if (context->callee().isFunction()) | ||||
126 | _id = context->callee().data().toUInt32(); | ||||
127 | else | ||||
128 | _id = 0xBABE0000 + 19; | ||||
129 | #endif | ||||
130 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
131 | _id &= 0x0000FFFF; | ||||
132 | QObject* _q_self = qscriptvalue_cast<QObject*>(context->thisObject()); | ||||
133 | if (!_q_self) { | ||||
134 | return context->throwError(QScriptContext::TypeError, | ||||
135 | QString::fromLatin1("QObject.%0(): this object is not a QObject") | ||||
136 | .arg(qtscript_QObject_function_names[_id+1])); | ||||
137 | } | ||||
138 | | ||||
139 | switch (_id) { | ||||
140 | case 0: | ||||
141 | if (context->argumentCount() == 1) { | ||||
142 | bool _q_arg0 = context->argument(0).toBoolean(); | ||||
143 | bool _q_result = _q_self->blockSignals(_q_arg0); | ||||
144 | return QScriptValue(context->engine(), _q_result); | ||||
145 | } | ||||
146 | break; | ||||
147 | | ||||
148 | case 1: | ||||
149 | if (context->argumentCount() == 0) { | ||||
150 | const QList<QObject* >& _q_result = _q_self->children(); | ||||
151 | return qScriptValueFromSequence(context->engine(), _q_result); | ||||
152 | } | ||||
153 | break; | ||||
154 | | ||||
155 | case 2: | ||||
156 | if (context->argumentCount() == 0) { | ||||
157 | _q_self->dumpObjectInfo(); | ||||
158 | return context->engine()->undefinedValue(); | ||||
159 | } | ||||
160 | break; | ||||
161 | | ||||
162 | case 3: | ||||
163 | if (context->argumentCount() == 0) { | ||||
164 | _q_self->dumpObjectTree(); | ||||
165 | return context->engine()->undefinedValue(); | ||||
166 | } | ||||
167 | break; | ||||
168 | | ||||
169 | case 4: | ||||
170 | if (context->argumentCount() == 0) { | ||||
171 | QList<QByteArray > _q_result = _q_self->dynamicPropertyNames(); | ||||
172 | return qScriptValueFromSequence(context->engine(), _q_result); | ||||
173 | } | ||||
174 | break; | ||||
175 | | ||||
176 | case 5: | ||||
177 | if (context->argumentCount() == 1) { | ||||
178 | QEvent* _q_arg0 = qscriptvalue_cast<QEvent*>(context->argument(0)); | ||||
179 | bool _q_result = _q_self->event(_q_arg0); | ||||
180 | return QScriptValue(context->engine(), _q_result); | ||||
181 | } | ||||
182 | break; | ||||
183 | | ||||
184 | case 6: | ||||
185 | if (context->argumentCount() == 2) { | ||||
186 | QObject* _q_arg0 = context->argument(0).toQObject(); | ||||
187 | QEvent* _q_arg1 = qscriptvalue_cast<QEvent*>(context->argument(1)); | ||||
188 | bool _q_result = _q_self->eventFilter(_q_arg0, _q_arg1); | ||||
189 | return QScriptValue(context->engine(), _q_result); | ||||
190 | } | ||||
191 | break; | ||||
192 | | ||||
193 | case 7: | ||||
194 | if (context->argumentCount() == 1) { | ||||
195 | | ||||
196 | // TEMPLATE - core.convert_string_arg_to_char* - START | ||||
197 | QByteArray tmp__q_arg0 = context->argument(0).toString().toLatin1(); | ||||
198 | const char * _q_arg0 = tmp__q_arg0.constData(); | ||||
199 | // TEMPLATE - core.convert_string_arg_to_char* - END | ||||
200 | bool _q_result = _q_self->inherits(_q_arg0); | ||||
201 | return QScriptValue(context->engine(), _q_result); | ||||
202 | } | ||||
203 | break; | ||||
204 | | ||||
205 | case 8: | ||||
206 | if (context->argumentCount() == 1) { | ||||
207 | QObject* _q_arg0 = context->argument(0).toQObject(); | ||||
208 | _q_self->installEventFilter(_q_arg0); | ||||
209 | return context->engine()->undefinedValue(); | ||||
210 | } | ||||
211 | break; | ||||
212 | | ||||
213 | case 9: | ||||
214 | if (context->argumentCount() == 0) { | ||||
215 | bool _q_result = _q_self->isWidgetType(); | ||||
216 | return QScriptValue(context->engine(), _q_result); | ||||
217 | } | ||||
218 | break; | ||||
219 | | ||||
220 | case 10: | ||||
221 | if (context->argumentCount() == 0) { | ||||
222 | bool _q_result = _q_self->isWindowType(); | ||||
223 | return QScriptValue(context->engine(), _q_result); | ||||
224 | } | ||||
225 | break; | ||||
226 | | ||||
227 | case 11: | ||||
228 | if (context->argumentCount() == 1) { | ||||
229 | int _q_arg0 = context->argument(0).toInt32(); | ||||
230 | _q_self->killTimer(_q_arg0); | ||||
231 | return context->engine()->undefinedValue(); | ||||
232 | } | ||||
233 | break; | ||||
234 | | ||||
235 | case 12: | ||||
236 | if (context->argumentCount() == 0) { | ||||
237 | QObject* _q_result = _q_self->parent(); | ||||
238 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
239 | } | ||||
240 | break; | ||||
241 | | ||||
242 | case 13: | ||||
243 | if (context->argumentCount() == 1) { | ||||
244 | | ||||
245 | // TEMPLATE - core.convert_string_arg_to_char* - START | ||||
246 | QByteArray tmp__q_arg0 = context->argument(0).toString().toLatin1(); | ||||
247 | const char * _q_arg0 = tmp__q_arg0.constData(); | ||||
248 | // TEMPLATE - core.convert_string_arg_to_char* - END | ||||
249 | QVariant _q_result = _q_self->property(_q_arg0); | ||||
250 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
251 | } | ||||
252 | break; | ||||
253 | | ||||
254 | case 14: | ||||
255 | if (context->argumentCount() == 1) { | ||||
256 | QObject* _q_arg0 = context->argument(0).toQObject(); | ||||
257 | _q_self->removeEventFilter(_q_arg0); | ||||
258 | return context->engine()->undefinedValue(); | ||||
259 | } | ||||
260 | break; | ||||
261 | | ||||
262 | case 15: | ||||
263 | if (context->argumentCount() == 1) { | ||||
264 | QObject* _q_arg0 = context->argument(0).toQObject(); | ||||
265 | _q_self->setParent(_q_arg0); | ||||
266 | return context->engine()->undefinedValue(); | ||||
267 | } | ||||
268 | break; | ||||
269 | | ||||
270 | case 16: | ||||
271 | if (context->argumentCount() == 2) { | ||||
272 | | ||||
273 | // TEMPLATE - core.convert_string_arg_to_char* - START | ||||
274 | QByteArray tmp__q_arg0 = context->argument(0).toString().toLatin1(); | ||||
275 | const char * _q_arg0 = tmp__q_arg0.constData(); | ||||
276 | // TEMPLATE - core.convert_string_arg_to_char* - END | ||||
277 | QVariant _q_arg1 = context->argument(1).toVariant(); | ||||
278 | bool _q_result = _q_self->setProperty(_q_arg0, _q_arg1); | ||||
279 | return QScriptValue(context->engine(), _q_result); | ||||
280 | } | ||||
281 | break; | ||||
282 | | ||||
283 | case 17: | ||||
284 | if (context->argumentCount() == 0) { | ||||
285 | bool _q_result = _q_self->signalsBlocked(); | ||||
286 | return QScriptValue(context->engine(), _q_result); | ||||
287 | } | ||||
288 | break; | ||||
289 | | ||||
290 | case 18: | ||||
291 | if (context->argumentCount() == 2) { | ||||
292 | int _q_arg0 = context->argument(0).toInt32(); | ||||
293 | Qt::TimerType _q_arg1 = qscriptvalue_cast<Qt::TimerType>(context->argument(1)); | ||||
294 | int _q_result = _q_self->startTimer(_q_arg0, _q_arg1); | ||||
295 | return QScriptValue(context->engine(), _q_result); | ||||
296 | } | ||||
297 | break; | ||||
298 | | ||||
299 | case 19: { | ||||
300 | QString result; | ||||
301 | QDebug d(&result); | ||||
302 | d << _q_self; | ||||
303 | return QScriptValue(context->engine(), result); | ||||
304 | } | ||||
305 | | ||||
306 | default: | ||||
307 | Q_ASSERT(false); | ||||
308 | } | ||||
309 | return qtscript_QObject_throw_ambiguity_error_helper(context, | ||||
310 | qtscript_QObject_function_names[_id+1], | ||||
311 | qtscript_QObject_function_signatures[_id+1]); | ||||
312 | } | ||||
313 | | ||||
314 | static QScriptValue qtscript_QObject_static_call(QScriptContext *context, QScriptEngine *) | ||||
315 | { | ||||
316 | uint _id = context->callee().data().toUInt32(); | ||||
317 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
318 | _id &= 0x0000FFFF; | ||||
319 | switch (_id) { | ||||
320 | case 0: | ||||
321 | if (context->thisObject().strictlyEquals(context->engine()->globalObject())) { | ||||
322 | return context->throwError(QString::fromLatin1("QObject(): Did you forget to construct with 'new'?")); | ||||
323 | } | ||||
324 | if (context->argumentCount() == 0) { | ||||
325 | QtScriptShell_QObject* _q_cpp_result = new QtScriptShell_QObject(); | ||||
326 | QScriptValue _q_result = context->engine()->newQObject(context->thisObject(), (QObject*)_q_cpp_result, QScriptEngine::AutoOwnership); | ||||
327 | _q_cpp_result->__qtscript_self = _q_result; | ||||
328 | return _q_result; | ||||
329 | } else if (context->argumentCount() == 1) { | ||||
330 | QObject* _q_arg0 = context->argument(0).toQObject(); | ||||
331 | QtScriptShell_QObject* _q_cpp_result = new QtScriptShell_QObject(_q_arg0); | ||||
332 | QScriptValue _q_result = context->engine()->newQObject(context->thisObject(), (QObject*)_q_cpp_result, QScriptEngine::AutoOwnership); | ||||
333 | _q_cpp_result->__qtscript_self = _q_result; | ||||
334 | return _q_result; | ||||
335 | } | ||||
336 | break; | ||||
337 | | ||||
338 | default: | ||||
339 | Q_ASSERT(false); | ||||
340 | } | ||||
341 | return qtscript_QObject_throw_ambiguity_error_helper(context, | ||||
342 | qtscript_QObject_function_names[_id], | ||||
343 | qtscript_QObject_function_signatures[_id]); | ||||
344 | } | ||||
345 | | ||||
346 | static QScriptValue qtscript_QObject_toScriptValue(QScriptEngine *engine, QObject* const &in) | ||||
347 | { | ||||
348 | return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::PreferExistingWrapperObject); | ||||
349 | } | ||||
350 | | ||||
351 | static void qtscript_QObject_fromScriptValue(const QScriptValue &value, QObject* &out) | ||||
352 | { | ||||
353 | out = qobject_cast<QObject*>(value.toQObject()); | ||||
354 | } | ||||
355 | | ||||
356 | QScriptValue qtscript_create_QObject_class(QScriptEngine *engine) | ||||
357 | { | ||||
358 | engine->setDefaultPrototype(qMetaTypeId<QObject*>(), QScriptValue()); | ||||
359 | QScriptValue proto = engine->newVariant(qVariantFromValue((QObject*)0)); | ||||
360 | for (int i = 0; i < 20; ++i) { | ||||
361 | QScriptValue fun = engine->newFunction(qtscript_QObject_prototype_call, qtscript_QObject_function_lengths[i+1]); | ||||
362 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i))); | ||||
363 | proto.setProperty(QString::fromLatin1(qtscript_QObject_function_names[i+1]), | ||||
364 | fun, QScriptValue::SkipInEnumeration); | ||||
365 | } | ||||
366 | | ||||
367 | qScriptRegisterMetaType<QObject*>(engine, qtscript_QObject_toScriptValue, | ||||
368 | qtscript_QObject_fromScriptValue, proto); | ||||
369 | | ||||
370 | QScriptValue ctor = engine->newFunction(qtscript_QObject_static_call, proto, qtscript_QObject_function_lengths[0]); | ||||
371 | ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0))); | ||||
372 | | ||||
373 | return ctor; | ||||
374 | } |