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