Differential D24817 Diff 68400 src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QRunnable.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QRunnable.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 <qrunnable.h> | ||||
10 | #include <QVariant> | ||||
11 | | ||||
12 | #include "qtscriptshell_QRunnable.h" | ||||
13 | | ||||
14 | static const char * const qtscript_QRunnable_function_names[] = { | ||||
15 | "QRunnable" | ||||
16 | // static | ||||
17 | // prototype | ||||
18 | , "autoDelete" | ||||
19 | , "run" | ||||
20 | , "setAutoDelete" | ||||
21 | , "toString" | ||||
22 | }; | ||||
23 | | ||||
24 | static const char * const qtscript_QRunnable_function_signatures[] = { | ||||
25 | "" | ||||
26 | // static | ||||
27 | // prototype | ||||
28 | , "" | ||||
29 | , "" | ||||
30 | , "bool _autoDelete" | ||||
31 | "" | ||||
32 | }; | ||||
33 | | ||||
34 | static const int qtscript_QRunnable_function_lengths[] = { | ||||
35 | 0 | ||||
36 | // static | ||||
37 | // prototype | ||||
38 | , 0 | ||||
39 | , 0 | ||||
40 | , 1 | ||||
41 | , 0 | ||||
42 | }; | ||||
43 | | ||||
44 | static QScriptValue qtscript_QRunnable_throw_ambiguity_error_helper( | ||||
45 | QScriptContext *context, const char *functionName, const char *signatures) | ||||
46 | { | ||||
47 | QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\n')); | ||||
48 | QStringList fullSignatures; | ||||
49 | for (int i = 0; i < lines.size(); ++i) | ||||
50 | fullSignatures.append(QString::fromLatin1("%0(%1)").arg(functionName).arg(lines.at(i))); | ||||
51 | return context->throwError(QString::fromLatin1("QRunnable::%0(): could not find a function match; candidates are:\n%1") | ||||
52 | .arg(functionName).arg(fullSignatures.join(QLatin1String("\n")))); | ||||
53 | } | ||||
54 | | ||||
55 | Q_DECLARE_METATYPE(QRunnable*) | ||||
56 | Q_DECLARE_METATYPE(QtScriptShell_QRunnable*) | ||||
57 | | ||||
58 | // | ||||
59 | // QRunnable | ||||
60 | // | ||||
61 | | ||||
62 | static QScriptValue qtscript_QRunnable_prototype_call(QScriptContext *context, QScriptEngine *) | ||||
63 | { | ||||
64 | #if QT_VERSION > 0x040400 | ||||
65 | Q_ASSERT(context->callee().isFunction()); | ||||
66 | uint _id = context->callee().data().toUInt32(); | ||||
67 | #else | ||||
68 | uint _id; | ||||
69 | if (context->callee().isFunction()) | ||||
70 | _id = context->callee().data().toUInt32(); | ||||
71 | else | ||||
72 | _id = 0xBABE0000 + 3; | ||||
73 | #endif | ||||
74 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
75 | _id &= 0x0000FFFF; | ||||
76 | QRunnable* _q_self = qscriptvalue_cast<QRunnable*>(context->thisObject()); | ||||
77 | if (!_q_self) { | ||||
78 | return context->throwError(QScriptContext::TypeError, | ||||
79 | QString::fromLatin1("QRunnable.%0(): this object is not a QRunnable") | ||||
80 | .arg(qtscript_QRunnable_function_names[_id+1])); | ||||
81 | } | ||||
82 | | ||||
83 | switch (_id) { | ||||
84 | case 0: | ||||
85 | if (context->argumentCount() == 0) { | ||||
86 | bool _q_result = _q_self->autoDelete(); | ||||
87 | return QScriptValue(context->engine(), _q_result); | ||||
88 | } | ||||
89 | break; | ||||
90 | | ||||
91 | case 1: | ||||
92 | if (context->argumentCount() == 0) { | ||||
93 | _q_self->run(); | ||||
94 | return context->engine()->undefinedValue(); | ||||
95 | } | ||||
96 | break; | ||||
97 | | ||||
98 | case 2: | ||||
99 | if (context->argumentCount() == 1) { | ||||
100 | bool _q_arg0 = context->argument(0).toBoolean(); | ||||
101 | _q_self->setAutoDelete(_q_arg0); | ||||
102 | return context->engine()->undefinedValue(); | ||||
103 | } | ||||
104 | break; | ||||
105 | | ||||
106 | case 3: { | ||||
107 | QString result = QString::fromLatin1("QRunnable"); | ||||
108 | return QScriptValue(context->engine(), result); | ||||
109 | } | ||||
110 | | ||||
111 | default: | ||||
112 | Q_ASSERT(false); | ||||
113 | } | ||||
114 | return qtscript_QRunnable_throw_ambiguity_error_helper(context, | ||||
115 | qtscript_QRunnable_function_names[_id+1], | ||||
116 | qtscript_QRunnable_function_signatures[_id+1]); | ||||
117 | } | ||||
118 | | ||||
119 | static QScriptValue qtscript_QRunnable_static_call(QScriptContext *context, QScriptEngine *) | ||||
120 | { | ||||
121 | uint _id = context->callee().data().toUInt32(); | ||||
122 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
123 | _id &= 0x0000FFFF; | ||||
124 | switch (_id) { | ||||
125 | case 0: | ||||
126 | if (context->thisObject().strictlyEquals(context->engine()->globalObject())) { | ||||
127 | return context->throwError(QString::fromLatin1("QRunnable(): Did you forget to construct with 'new'?")); | ||||
128 | } | ||||
129 | if (context->argumentCount() == 0) { | ||||
130 | QtScriptShell_QRunnable* _q_cpp_result = new QtScriptShell_QRunnable(); | ||||
131 | QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue((QRunnable*)_q_cpp_result)); | ||||
132 | _q_cpp_result->__qtscript_self = _q_result; | ||||
133 | return _q_result; | ||||
134 | } | ||||
135 | break; | ||||
136 | | ||||
137 | default: | ||||
138 | Q_ASSERT(false); | ||||
139 | } | ||||
140 | return qtscript_QRunnable_throw_ambiguity_error_helper(context, | ||||
141 | qtscript_QRunnable_function_names[_id], | ||||
142 | qtscript_QRunnable_function_signatures[_id]); | ||||
143 | } | ||||
144 | | ||||
145 | QScriptValue qtscript_create_QRunnable_class(QScriptEngine *engine) | ||||
146 | { | ||||
147 | engine->setDefaultPrototype(qMetaTypeId<QRunnable*>(), QScriptValue()); | ||||
148 | QScriptValue proto = engine->newVariant(qVariantFromValue((QRunnable*)0)); | ||||
149 | for (int i = 0; i < 4; ++i) { | ||||
150 | QScriptValue fun = engine->newFunction(qtscript_QRunnable_prototype_call, qtscript_QRunnable_function_lengths[i+1]); | ||||
151 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i))); | ||||
152 | proto.setProperty(QString::fromLatin1(qtscript_QRunnable_function_names[i+1]), | ||||
153 | fun, QScriptValue::SkipInEnumeration); | ||||
154 | } | ||||
155 | | ||||
156 | engine->setDefaultPrototype(qMetaTypeId<QRunnable*>(), proto); | ||||
157 | | ||||
158 | QScriptValue ctor = engine->newFunction(qtscript_QRunnable_static_call, proto, qtscript_QRunnable_function_lengths[0]); | ||||
159 | ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0))); | ||||
160 | | ||||
161 | return ctor; | ||||
162 | } |