Differential D24817 Diff 68400 src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QCryptographicHash.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QCryptographicHash.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 <qcryptographichash.h> | ||||
10 | #include <QVariant> | ||||
11 | #include <qbytearray.h> | ||||
12 | #include <qcryptographichash.h> | ||||
13 | #include <qiodevice.h> | ||||
14 | | ||||
15 | static const char * const qtscript_QCryptographicHash_function_names[] = { | ||||
16 | "QCryptographicHash" | ||||
17 | // static | ||||
18 | , "hash" | ||||
19 | // prototype | ||||
20 | , "addData" | ||||
21 | , "reset" | ||||
22 | , "result" | ||||
23 | , "toString" | ||||
24 | }; | ||||
25 | | ||||
26 | static const char * const qtscript_QCryptographicHash_function_signatures[] = { | ||||
27 | "Algorithm method" | ||||
28 | // static | ||||
29 | , "QByteArray data, Algorithm method" | ||||
30 | // prototype | ||||
31 | , "QIODevice device\nQByteArray data" | ||||
32 | , "" | ||||
33 | , "" | ||||
34 | "" | ||||
35 | }; | ||||
36 | | ||||
37 | static const int qtscript_QCryptographicHash_function_lengths[] = { | ||||
38 | 1 | ||||
39 | // static | ||||
40 | , 2 | ||||
41 | // prototype | ||||
42 | , 1 | ||||
43 | , 0 | ||||
44 | , 0 | ||||
45 | , 0 | ||||
46 | }; | ||||
47 | | ||||
48 | static QScriptValue qtscript_QCryptographicHash_throw_ambiguity_error_helper( | ||||
49 | QScriptContext *context, const char *functionName, const char *signatures) | ||||
50 | { | ||||
51 | QStringList lines = QString::fromLatin1(signatures).split(QLatin1Char('\n')); | ||||
52 | QStringList fullSignatures; | ||||
53 | for (int i = 0; i < lines.size(); ++i) | ||||
54 | fullSignatures.append(QString::fromLatin1("%0(%1)").arg(functionName).arg(lines.at(i))); | ||||
55 | return context->throwError(QString::fromLatin1("QCryptographicHash::%0(): could not find a function match; candidates are:\n%1") | ||||
56 | .arg(functionName).arg(fullSignatures.join(QLatin1String("\n")))); | ||||
57 | } | ||||
58 | | ||||
59 | Q_DECLARE_METATYPE(QCryptographicHash*) | ||||
60 | Q_DECLARE_METATYPE(QCryptographicHash::Algorithm) | ||||
61 | Q_DECLARE_METATYPE(QIODevice*) | ||||
62 | | ||||
63 | static QScriptValue qtscript_create_enum_class_helper( | ||||
64 | QScriptEngine *engine, | ||||
65 | QScriptEngine::FunctionSignature construct, | ||||
66 | QScriptEngine::FunctionSignature valueOf, | ||||
67 | QScriptEngine::FunctionSignature toString) | ||||
68 | { | ||||
69 | QScriptValue proto = engine->newObject(); | ||||
70 | proto.setProperty(QString::fromLatin1("valueOf"), | ||||
71 | engine->newFunction(valueOf), QScriptValue::SkipInEnumeration); | ||||
72 | proto.setProperty(QString::fromLatin1("toString"), | ||||
73 | engine->newFunction(toString), QScriptValue::SkipInEnumeration); | ||||
74 | return engine->newFunction(construct, proto, 1); | ||||
75 | } | ||||
76 | | ||||
77 | // | ||||
78 | // QCryptographicHash::Algorithm | ||||
79 | // | ||||
80 | | ||||
81 | static const QCryptographicHash::Algorithm qtscript_QCryptographicHash_Algorithm_values[] = { | ||||
82 | QCryptographicHash::Md4 | ||||
83 | , QCryptographicHash::Md5 | ||||
84 | , QCryptographicHash::Sha1 | ||||
85 | , QCryptographicHash::Sha224 | ||||
86 | , QCryptographicHash::Sha256 | ||||
87 | , QCryptographicHash::Sha384 | ||||
88 | , QCryptographicHash::Sha512 | ||||
89 | , QCryptographicHash::Sha3_224 | ||||
90 | , QCryptographicHash::Sha3_256 | ||||
91 | , QCryptographicHash::Sha3_384 | ||||
92 | , QCryptographicHash::Sha3_512 | ||||
93 | }; | ||||
94 | | ||||
95 | static const char * const qtscript_QCryptographicHash_Algorithm_keys[] = { | ||||
96 | "Md4" | ||||
97 | , "Md5" | ||||
98 | , "Sha1" | ||||
99 | , "Sha224" | ||||
100 | , "Sha256" | ||||
101 | , "Sha384" | ||||
102 | , "Sha512" | ||||
103 | , "Sha3_224" | ||||
104 | , "Sha3_256" | ||||
105 | , "Sha3_384" | ||||
106 | , "Sha3_512" | ||||
107 | }; | ||||
108 | | ||||
109 | static QString qtscript_QCryptographicHash_Algorithm_toStringHelper(QCryptographicHash::Algorithm value) | ||||
110 | { | ||||
111 | if ((value >= QCryptographicHash::Md4) && (value <= QCryptographicHash::Sha3_512)) | ||||
112 | return qtscript_QCryptographicHash_Algorithm_keys[static_cast<int>(value)-static_cast<int>(QCryptographicHash::Md4)]; | ||||
113 | return QString(); | ||||
114 | } | ||||
115 | | ||||
116 | static QScriptValue qtscript_QCryptographicHash_Algorithm_toScriptValue(QScriptEngine *engine, const QCryptographicHash::Algorithm &value) | ||||
117 | { | ||||
118 | QScriptValue clazz = engine->globalObject().property(QString::fromLatin1("QCryptographicHash")); | ||||
119 | return clazz.property(qtscript_QCryptographicHash_Algorithm_toStringHelper(value)); | ||||
120 | } | ||||
121 | | ||||
122 | static void qtscript_QCryptographicHash_Algorithm_fromScriptValue(const QScriptValue &value, QCryptographicHash::Algorithm &out) | ||||
123 | { | ||||
124 | out = qvariant_cast<QCryptographicHash::Algorithm>(value.toVariant()); | ||||
125 | } | ||||
126 | | ||||
127 | static QScriptValue qtscript_construct_QCryptographicHash_Algorithm(QScriptContext *context, QScriptEngine *engine) | ||||
128 | { | ||||
129 | int arg = context->argument(0).toInt32(); | ||||
130 | if ((arg >= QCryptographicHash::Md4) && (arg <= QCryptographicHash::Sha3_512)) | ||||
131 | return qScriptValueFromValue(engine, static_cast<QCryptographicHash::Algorithm>(arg)); | ||||
132 | return context->throwError(QString::fromLatin1("Algorithm(): invalid enum value (%0)").arg(arg)); | ||||
133 | } | ||||
134 | | ||||
135 | static QScriptValue qtscript_QCryptographicHash_Algorithm_valueOf(QScriptContext *context, QScriptEngine *engine) | ||||
136 | { | ||||
137 | QCryptographicHash::Algorithm value = qscriptvalue_cast<QCryptographicHash::Algorithm>(context->thisObject()); | ||||
138 | return QScriptValue(engine, static_cast<int>(value)); | ||||
139 | } | ||||
140 | | ||||
141 | static QScriptValue qtscript_QCryptographicHash_Algorithm_toString(QScriptContext *context, QScriptEngine *engine) | ||||
142 | { | ||||
143 | QCryptographicHash::Algorithm value = qscriptvalue_cast<QCryptographicHash::Algorithm>(context->thisObject()); | ||||
144 | return QScriptValue(engine, qtscript_QCryptographicHash_Algorithm_toStringHelper(value)); | ||||
145 | } | ||||
146 | | ||||
147 | static QScriptValue qtscript_create_QCryptographicHash_Algorithm_class(QScriptEngine *engine, QScriptValue &clazz) | ||||
148 | { | ||||
149 | QScriptValue ctor = qtscript_create_enum_class_helper( | ||||
150 | engine, qtscript_construct_QCryptographicHash_Algorithm, | ||||
151 | qtscript_QCryptographicHash_Algorithm_valueOf, qtscript_QCryptographicHash_Algorithm_toString); | ||||
152 | qScriptRegisterMetaType<QCryptographicHash::Algorithm>(engine, qtscript_QCryptographicHash_Algorithm_toScriptValue, | ||||
153 | qtscript_QCryptographicHash_Algorithm_fromScriptValue, ctor.property(QString::fromLatin1("prototype"))); | ||||
154 | for (int i = 0; i < 11; ++i) { | ||||
155 | clazz.setProperty(QString::fromLatin1(qtscript_QCryptographicHash_Algorithm_keys[i]), | ||||
156 | engine->newVariant(qVariantFromValue(qtscript_QCryptographicHash_Algorithm_values[i])), | ||||
157 | QScriptValue::ReadOnly | QScriptValue::Undeletable); | ||||
158 | } | ||||
159 | return ctor; | ||||
160 | } | ||||
161 | | ||||
162 | // | ||||
163 | // QCryptographicHash | ||||
164 | // | ||||
165 | | ||||
166 | static QScriptValue qtscript_QCryptographicHash_prototype_call(QScriptContext *context, QScriptEngine *) | ||||
167 | { | ||||
168 | #if QT_VERSION > 0x040400 | ||||
169 | Q_ASSERT(context->callee().isFunction()); | ||||
170 | uint _id = context->callee().data().toUInt32(); | ||||
171 | #else | ||||
172 | uint _id; | ||||
173 | if (context->callee().isFunction()) | ||||
174 | _id = context->callee().data().toUInt32(); | ||||
175 | else | ||||
176 | _id = 0xBABE0000 + 3; | ||||
177 | #endif | ||||
178 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
179 | _id &= 0x0000FFFF; | ||||
180 | QCryptographicHash* _q_self = qscriptvalue_cast<QCryptographicHash*>(context->thisObject()); | ||||
181 | if (!_q_self) { | ||||
182 | return context->throwError(QScriptContext::TypeError, | ||||
183 | QString::fromLatin1("QCryptographicHash.%0(): this object is not a QCryptographicHash") | ||||
184 | .arg(qtscript_QCryptographicHash_function_names[_id+2])); | ||||
185 | } | ||||
186 | | ||||
187 | switch (_id) { | ||||
188 | case 0: | ||||
189 | if (context->argumentCount() == 1) { | ||||
190 | if (qscriptvalue_cast<QIODevice*>(context->argument(0))) { | ||||
191 | QIODevice* _q_arg0 = qscriptvalue_cast<QIODevice*>(context->argument(0)); | ||||
192 | bool _q_result = _q_self->addData(_q_arg0); | ||||
193 | return QScriptValue(context->engine(), _q_result); | ||||
194 | } else if ((qMetaTypeId<QByteArray>() == context->argument(0).toVariant().userType())) { | ||||
195 | QByteArray _q_arg0 = qscriptvalue_cast<QByteArray>(context->argument(0)); | ||||
196 | _q_self->addData(_q_arg0); | ||||
197 | return context->engine()->undefinedValue(); | ||||
198 | } | ||||
199 | } | ||||
200 | break; | ||||
201 | | ||||
202 | case 1: | ||||
203 | if (context->argumentCount() == 0) { | ||||
204 | _q_self->reset(); | ||||
205 | return context->engine()->undefinedValue(); | ||||
206 | } | ||||
207 | break; | ||||
208 | | ||||
209 | case 2: | ||||
210 | if (context->argumentCount() == 0) { | ||||
211 | QByteArray _q_result = _q_self->result(); | ||||
212 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
213 | } | ||||
214 | break; | ||||
215 | | ||||
216 | case 3: { | ||||
217 | QString result = QString::fromLatin1("QCryptographicHash"); | ||||
218 | return QScriptValue(context->engine(), result); | ||||
219 | } | ||||
220 | | ||||
221 | default: | ||||
222 | Q_ASSERT(false); | ||||
223 | } | ||||
224 | return qtscript_QCryptographicHash_throw_ambiguity_error_helper(context, | ||||
225 | qtscript_QCryptographicHash_function_names[_id+2], | ||||
226 | qtscript_QCryptographicHash_function_signatures[_id+2]); | ||||
227 | } | ||||
228 | | ||||
229 | static QScriptValue qtscript_QCryptographicHash_static_call(QScriptContext *context, QScriptEngine *) | ||||
230 | { | ||||
231 | uint _id = context->callee().data().toUInt32(); | ||||
232 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
233 | _id &= 0x0000FFFF; | ||||
234 | switch (_id) { | ||||
235 | case 0: | ||||
236 | if (context->thisObject().strictlyEquals(context->engine()->globalObject())) { | ||||
237 | return context->throwError(QString::fromLatin1("QCryptographicHash(): Did you forget to construct with 'new'?")); | ||||
238 | } | ||||
239 | if (context->argumentCount() == 1) { | ||||
240 | QCryptographicHash::Algorithm _q_arg0 = qscriptvalue_cast<QCryptographicHash::Algorithm>(context->argument(0)); | ||||
241 | QCryptographicHash* _q_cpp_result = new QCryptographicHash(_q_arg0); | ||||
242 | QScriptValue _q_result = context->engine()->newVariant(context->thisObject(), qVariantFromValue(_q_cpp_result)); | ||||
243 | return _q_result; | ||||
244 | } | ||||
245 | break; | ||||
246 | | ||||
247 | case 1: | ||||
248 | if (context->argumentCount() == 2) { | ||||
249 | QByteArray _q_arg0 = qscriptvalue_cast<QByteArray>(context->argument(0)); | ||||
250 | QCryptographicHash::Algorithm _q_arg1 = qscriptvalue_cast<QCryptographicHash::Algorithm>(context->argument(1)); | ||||
251 | QByteArray _q_result = QCryptographicHash::hash(_q_arg0, _q_arg1); | ||||
252 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
253 | } | ||||
254 | break; | ||||
255 | | ||||
256 | default: | ||||
257 | Q_ASSERT(false); | ||||
258 | } | ||||
259 | return qtscript_QCryptographicHash_throw_ambiguity_error_helper(context, | ||||
260 | qtscript_QCryptographicHash_function_names[_id], | ||||
261 | qtscript_QCryptographicHash_function_signatures[_id]); | ||||
262 | } | ||||
263 | | ||||
264 | QScriptValue qtscript_create_QCryptographicHash_class(QScriptEngine *engine) | ||||
265 | { | ||||
266 | engine->setDefaultPrototype(qMetaTypeId<QCryptographicHash*>(), QScriptValue()); | ||||
267 | QScriptValue proto = engine->newVariant(qVariantFromValue((QCryptographicHash*)0)); | ||||
268 | for (int i = 0; i < 4; ++i) { | ||||
269 | QScriptValue fun = engine->newFunction(qtscript_QCryptographicHash_prototype_call, qtscript_QCryptographicHash_function_lengths[i+2]); | ||||
270 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i))); | ||||
271 | proto.setProperty(QString::fromLatin1(qtscript_QCryptographicHash_function_names[i+2]), | ||||
272 | fun, QScriptValue::SkipInEnumeration); | ||||
273 | } | ||||
274 | | ||||
275 | engine->setDefaultPrototype(qMetaTypeId<QCryptographicHash*>(), proto); | ||||
276 | | ||||
277 | QScriptValue ctor = engine->newFunction(qtscript_QCryptographicHash_static_call, proto, qtscript_QCryptographicHash_function_lengths[0]); | ||||
278 | ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0))); | ||||
279 | for (int i = 0; i < 1; ++i) { | ||||
280 | QScriptValue fun = engine->newFunction(qtscript_QCryptographicHash_static_call, | ||||
281 | qtscript_QCryptographicHash_function_lengths[i+1]); | ||||
282 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i+1))); | ||||
283 | ctor.setProperty(QString::fromLatin1(qtscript_QCryptographicHash_function_names[i+1]), | ||||
284 | fun, QScriptValue::SkipInEnumeration); | ||||
285 | } | ||||
286 | | ||||
287 | ctor.setProperty(QString::fromLatin1("Algorithm"), | ||||
288 | qtscript_create_QCryptographicHash_Algorithm_class(engine, ctor)); | ||||
289 | return ctor; | ||||
290 | } |