Differential D24817 Diff 68400 src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QTranslator.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QTranslator.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 <qtranslator.h> | ||||
10 | #include <QVariant> | ||||
11 | #include <qbytearray.h> | ||||
12 | #include <qcoreevent.h> | ||||
13 | #include <qlist.h> | ||||
14 | #include <qlocale.h> | ||||
15 | #include <qobject.h> | ||||
16 | #include <qtranslator.h> | ||||
17 | | ||||
18 | #include "qtscriptshell_QTranslator.h" | ||||
19 | | ||||
20 | static const char * const qtscript_QTranslator_function_names[] = { | ||||
21 | "QTranslator" | ||||
22 | // static | ||||
23 | // prototype | ||||
24 | , "isEmpty" | ||||
25 | , "load" | ||||
26 | , "toString" | ||||
27 | }; | ||||
28 | | ||||
29 | static const char * const qtscript_QTranslator_function_signatures[] = { | ||||
30 | "QObject parent" | ||||
31 | // static | ||||
32 | // prototype | ||||
33 | , "" | ||||
34 | , "QLocale locale, String filename, String prefix, String directory, String suffix\nString filename, String directory, String search_delimiters, String suffix\nuchar data, int len, String directory" | ||||
35 | "" | ||||
36 | }; | ||||
37 | | ||||
38 | static const int qtscript_QTranslator_function_lengths[] = { | ||||
39 | 1 | ||||
40 | // static | ||||
41 | // prototype | ||||
42 | , 0 | ||||
43 | , 5 | ||||
44 | , 0 | ||||
45 | }; | ||||
46 | | ||||
47 | static QScriptValue qtscript_QTranslator_throw_ambiguity_error_helper( | ||||
48 | QScriptContext *context, const char *functionName, const char *signatures) | ||||
49 | { | ||||
50 | QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\n')); | ||||
51 | QStringList fullSignatures; | ||||
52 | for (int i = 0; i < lines.size(); ++i) | ||||
53 | fullSignatures.append(QString::fromLatin1("%0(%1)").arg(functionName).arg(lines.at(i))); | ||||
54 | return context->throwError(QString::fromLatin1("QTranslator::%0(): could not find a function match; candidates are:\n%1") | ||||
55 | .arg(functionName).arg(fullSignatures.join(QLatin1String("\n")))); | ||||
56 | } | ||||
57 | | ||||
58 | Q_DECLARE_METATYPE(QTranslator*) | ||||
59 | Q_DECLARE_METATYPE(QtScriptShell_QTranslator*) | ||||
60 | Q_DECLARE_METATYPE(const uchar*) | ||||
61 | | ||||
62 | // | ||||
63 | // QTranslator | ||||
64 | // | ||||
65 | | ||||
66 | static QScriptValue qtscript_QTranslator_prototype_call(QScriptContext *context, QScriptEngine *) | ||||
67 | { | ||||
68 | #if QT_VERSION > 0x040400 | ||||
69 | Q_ASSERT(context->callee().isFunction()); | ||||
70 | uint _id = context->callee().data().toUInt32(); | ||||
71 | #else | ||||
72 | uint _id; | ||||
73 | if (context->callee().isFunction()) | ||||
74 | _id = context->callee().data().toUInt32(); | ||||
75 | else | ||||
76 | _id = 0xBABE0000 + 2; | ||||
77 | #endif | ||||
78 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
79 | _id &= 0x0000FFFF; | ||||
80 | QTranslator* _q_self = qscriptvalue_cast<QTranslator*>(context->thisObject()); | ||||
81 | if (!_q_self) { | ||||
82 | return context->throwError(QScriptContext::TypeError, | ||||
83 | QString::fromLatin1("QTranslator.%0(): this object is not a QTranslator") | ||||
84 | .arg(qtscript_QTranslator_function_names[_id+1])); | ||||
85 | } | ||||
86 | | ||||
87 | switch (_id) { | ||||
88 | case 0: | ||||
89 | if (context->argumentCount() == 0) { | ||||
90 | bool _q_result = _q_self->isEmpty(); | ||||
91 | return QScriptValue(context->engine(), _q_result); | ||||
92 | } | ||||
93 | break; | ||||
94 | | ||||
95 | case 1: | ||||
96 | if (context->argumentCount() == 1) { | ||||
97 | QString _q_arg0 = context->argument(0).toString(); | ||||
98 | bool _q_result = _q_self->load(_q_arg0); | ||||
99 | return QScriptValue(context->engine(), _q_result); | ||||
100 | } | ||||
101 | if (context->argumentCount() == 2) { | ||||
102 | if ((qMetaTypeId<QLocale>() == context->argument(0).toVariant().userType()) | ||||
103 | && context->argument(1).isString()) { | ||||
104 | QLocale _q_arg0 = qscriptvalue_cast<QLocale>(context->argument(0)); | ||||
105 | QString _q_arg1 = context->argument(1).toString(); | ||||
106 | bool _q_result = _q_self->load(_q_arg0, _q_arg1); | ||||
107 | return QScriptValue(context->engine(), _q_result); | ||||
108 | } else if (context->argument(0).isString() | ||||
109 | && context->argument(1).isString()) { | ||||
110 | QString _q_arg0 = context->argument(0).toString(); | ||||
111 | QString _q_arg1 = context->argument(1).toString(); | ||||
112 | bool _q_result = _q_self->load(_q_arg0, _q_arg1); | ||||
113 | return QScriptValue(context->engine(), _q_result); | ||||
114 | } else if (qscriptvalue_cast<const uchar*>(context->argument(0)) | ||||
115 | && context->argument(1).isNumber()) { | ||||
116 | const uchar* _q_arg0 = qscriptvalue_cast<const uchar*>(context->argument(0)); | ||||
117 | int _q_arg1 = context->argument(1).toInt32(); | ||||
118 | bool _q_result = _q_self->load(_q_arg0, _q_arg1); | ||||
119 | return QScriptValue(context->engine(), _q_result); | ||||
120 | } | ||||
121 | } | ||||
122 | if (context->argumentCount() == 3) { | ||||
123 | if ((qMetaTypeId<QLocale>() == context->argument(0).toVariant().userType()) | ||||
124 | && context->argument(1).isString() | ||||
125 | && context->argument(2).isString()) { | ||||
126 | QLocale _q_arg0 = qscriptvalue_cast<QLocale>(context->argument(0)); | ||||
127 | QString _q_arg1 = context->argument(1).toString(); | ||||
128 | QString _q_arg2 = context->argument(2).toString(); | ||||
129 | bool _q_result = _q_self->load(_q_arg0, _q_arg1, _q_arg2); | ||||
130 | return QScriptValue(context->engine(), _q_result); | ||||
131 | } else if (context->argument(0).isString() | ||||
132 | && context->argument(1).isString() | ||||
133 | && context->argument(2).isString()) { | ||||
134 | QString _q_arg0 = context->argument(0).toString(); | ||||
135 | QString _q_arg1 = context->argument(1).toString(); | ||||
136 | QString _q_arg2 = context->argument(2).toString(); | ||||
137 | bool _q_result = _q_self->load(_q_arg0, _q_arg1, _q_arg2); | ||||
138 | return QScriptValue(context->engine(), _q_result); | ||||
139 | } else if (qscriptvalue_cast<const uchar*>(context->argument(0)) | ||||
140 | && context->argument(1).isNumber() | ||||
141 | && context->argument(2).isString()) { | ||||
142 | const uchar* _q_arg0 = qscriptvalue_cast<const uchar*>(context->argument(0)); | ||||
143 | int _q_arg1 = context->argument(1).toInt32(); | ||||
144 | QString _q_arg2 = context->argument(2).toString(); | ||||
145 | bool _q_result = _q_self->load(_q_arg0, _q_arg1, _q_arg2); | ||||
146 | return QScriptValue(context->engine(), _q_result); | ||||
147 | } | ||||
148 | } | ||||
149 | if (context->argumentCount() == 4) { | ||||
150 | if ((qMetaTypeId<QLocale>() == context->argument(0).toVariant().userType()) | ||||
151 | && context->argument(1).isString() | ||||
152 | && context->argument(2).isString() | ||||
153 | && context->argument(3).isString()) { | ||||
154 | QLocale _q_arg0 = qscriptvalue_cast<QLocale>(context->argument(0)); | ||||
155 | QString _q_arg1 = context->argument(1).toString(); | ||||
156 | QString _q_arg2 = context->argument(2).toString(); | ||||
157 | QString _q_arg3 = context->argument(3).toString(); | ||||
158 | bool _q_result = _q_self->load(_q_arg0, _q_arg1, _q_arg2, _q_arg3); | ||||
159 | return QScriptValue(context->engine(), _q_result); | ||||
160 | } else if (context->argument(0).isString() | ||||
161 | && context->argument(1).isString() | ||||
162 | && context->argument(2).isString() | ||||
163 | && context->argument(3).isString()) { | ||||
164 | QString _q_arg0 = context->argument(0).toString(); | ||||
165 | QString _q_arg1 = context->argument(1).toString(); | ||||
166 | QString _q_arg2 = context->argument(2).toString(); | ||||
167 | QString _q_arg3 = context->argument(3).toString(); | ||||
168 | bool _q_result = _q_self->load(_q_arg0, _q_arg1, _q_arg2, _q_arg3); | ||||
169 | return QScriptValue(context->engine(), _q_result); | ||||
170 | } | ||||
171 | } | ||||
172 | if (context->argumentCount() == 5) { | ||||
173 | QLocale _q_arg0 = qscriptvalue_cast<QLocale>(context->argument(0)); | ||||
174 | QString _q_arg1 = context->argument(1).toString(); | ||||
175 | QString _q_arg2 = context->argument(2).toString(); | ||||
176 | QString _q_arg3 = context->argument(3).toString(); | ||||
177 | QString _q_arg4 = context->argument(4).toString(); | ||||
178 | bool _q_result = _q_self->load(_q_arg0, _q_arg1, _q_arg2, _q_arg3, _q_arg4); | ||||
179 | return QScriptValue(context->engine(), _q_result); | ||||
180 | } | ||||
181 | break; | ||||
182 | | ||||
183 | case 2: { | ||||
184 | QString result = QString::fromLatin1("QTranslator"); | ||||
185 | return QScriptValue(context->engine(), result); | ||||
186 | } | ||||
187 | | ||||
188 | default: | ||||
189 | Q_ASSERT(false); | ||||
190 | } | ||||
191 | return qtscript_QTranslator_throw_ambiguity_error_helper(context, | ||||
192 | qtscript_QTranslator_function_names[_id+1], | ||||
193 | qtscript_QTranslator_function_signatures[_id+1]); | ||||
194 | } | ||||
195 | | ||||
196 | static QScriptValue qtscript_QTranslator_static_call(QScriptContext *context, QScriptEngine *) | ||||
197 | { | ||||
198 | uint _id = context->callee().data().toUInt32(); | ||||
199 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
200 | _id &= 0x0000FFFF; | ||||
201 | switch (_id) { | ||||
202 | case 0: | ||||
203 | if (context->thisObject().strictlyEquals(context->engine()->globalObject())) { | ||||
204 | return context->throwError(QString::fromLatin1("QTranslator(): Did you forget to construct with 'new'?")); | ||||
205 | } | ||||
206 | if (context->argumentCount() == 0) { | ||||
207 | QtScriptShell_QTranslator* _q_cpp_result = new QtScriptShell_QTranslator(); | ||||
208 | QScriptValue _q_result = context->engine()->newQObject(context->thisObject(), (QTranslator*)_q_cpp_result, QScriptEngine::AutoOwnership); | ||||
209 | _q_cpp_result->__qtscript_self = _q_result; | ||||
210 | return _q_result; | ||||
211 | } else if (context->argumentCount() == 1) { | ||||
212 | QObject* _q_arg0 = context->argument(0).toQObject(); | ||||
213 | QtScriptShell_QTranslator* _q_cpp_result = new QtScriptShell_QTranslator(_q_arg0); | ||||
214 | QScriptValue _q_result = context->engine()->newQObject(context->thisObject(), (QTranslator*)_q_cpp_result, QScriptEngine::AutoOwnership); | ||||
215 | _q_cpp_result->__qtscript_self = _q_result; | ||||
216 | return _q_result; | ||||
217 | } | ||||
218 | break; | ||||
219 | | ||||
220 | default: | ||||
221 | Q_ASSERT(false); | ||||
222 | } | ||||
223 | return qtscript_QTranslator_throw_ambiguity_error_helper(context, | ||||
224 | qtscript_QTranslator_function_names[_id], | ||||
225 | qtscript_QTranslator_function_signatures[_id]); | ||||
226 | } | ||||
227 | | ||||
228 | static QScriptValue qtscript_QTranslator_toScriptValue(QScriptEngine *engine, QTranslator* const &in) | ||||
229 | { | ||||
230 | return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::PreferExistingWrapperObject); | ||||
231 | } | ||||
232 | | ||||
233 | static void qtscript_QTranslator_fromScriptValue(const QScriptValue &value, QTranslator* &out) | ||||
234 | { | ||||
235 | out = qobject_cast<QTranslator*>(value.toQObject()); | ||||
236 | } | ||||
237 | | ||||
238 | QScriptValue qtscript_create_QTranslator_class(QScriptEngine *engine) | ||||
239 | { | ||||
240 | engine->setDefaultPrototype(qMetaTypeId<QTranslator*>(), QScriptValue()); | ||||
241 | QScriptValue proto = engine->newVariant(qVariantFromValue((QTranslator*)0)); | ||||
242 | proto.setPrototype(engine->defaultPrototype(qMetaTypeId<QObject*>())); | ||||
243 | for (int i = 0; i < 3; ++i) { | ||||
244 | QScriptValue fun = engine->newFunction(qtscript_QTranslator_prototype_call, qtscript_QTranslator_function_lengths[i+1]); | ||||
245 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i))); | ||||
246 | proto.setProperty(QString::fromLatin1(qtscript_QTranslator_function_names[i+1]), | ||||
247 | fun, QScriptValue::SkipInEnumeration); | ||||
248 | } | ||||
249 | | ||||
250 | qScriptRegisterMetaType<QTranslator*>(engine, qtscript_QTranslator_toScriptValue, | ||||
251 | qtscript_QTranslator_fromScriptValue, proto); | ||||
252 | | ||||
253 | QScriptValue ctor = engine->newFunction(qtscript_QTranslator_static_call, proto, qtscript_QTranslator_function_lengths[0]); | ||||
254 | ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0))); | ||||
255 | | ||||
256 | return ctor; | ||||
257 | } |