Differential D24817 Diff 68400 src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QSocketNotifier.cpp
Changeset View
Changeset View
Standalone View
Standalone View
src/scripting/qtbindings/generated_cpp/com_trolltech_qt_core/qtscript_QSocketNotifier.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 <qsocketnotifier.h> | ||||
10 | #include <QVariant> | ||||
11 | #include <qbytearray.h> | ||||
12 | #include <qcoreevent.h> | ||||
13 | #include <qlist.h> | ||||
14 | #include <qobject.h> | ||||
15 | #include <qsocketnotifier.h> | ||||
16 | | ||||
17 | static const char * const qtscript_QSocketNotifier_function_names[] = { | ||||
18 | "QSocketNotifier" | ||||
19 | // static | ||||
20 | // prototype | ||||
21 | , "isEnabled" | ||||
22 | , "type" | ||||
23 | , "toString" | ||||
24 | }; | ||||
25 | | ||||
26 | static const char * const qtscript_QSocketNotifier_function_signatures[] = { | ||||
27 | "" | ||||
28 | // static | ||||
29 | // prototype | ||||
30 | , "" | ||||
31 | , "" | ||||
32 | "" | ||||
33 | }; | ||||
34 | | ||||
35 | static const int qtscript_QSocketNotifier_function_lengths[] = { | ||||
36 | 0 | ||||
37 | // static | ||||
38 | // prototype | ||||
39 | , 0 | ||||
40 | , 0 | ||||
41 | , 0 | ||||
42 | }; | ||||
43 | | ||||
44 | static QScriptValue qtscript_QSocketNotifier_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("QSocketNotifier::%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(QSocketNotifier*) | ||||
56 | Q_DECLARE_METATYPE(QSocketNotifier::Type) | ||||
57 | | ||||
58 | static QScriptValue qtscript_create_enum_class_helper( | ||||
59 | QScriptEngine *engine, | ||||
60 | QScriptEngine::FunctionSignature construct, | ||||
61 | QScriptEngine::FunctionSignature valueOf, | ||||
62 | QScriptEngine::FunctionSignature toString) | ||||
63 | { | ||||
64 | QScriptValue proto = engine->newObject(); | ||||
65 | proto.setProperty(QString::fromLatin1("valueOf"), | ||||
66 | engine->newFunction(valueOf), QScriptValue::SkipInEnumeration); | ||||
67 | proto.setProperty(QString::fromLatin1("toString"), | ||||
68 | engine->newFunction(toString), QScriptValue::SkipInEnumeration); | ||||
69 | return engine->newFunction(construct, proto, 1); | ||||
70 | } | ||||
71 | | ||||
72 | // | ||||
73 | // QSocketNotifier::Type | ||||
74 | // | ||||
75 | | ||||
76 | static const QSocketNotifier::Type qtscript_QSocketNotifier_Type_values[] = { | ||||
77 | QSocketNotifier::Read | ||||
78 | , QSocketNotifier::Write | ||||
79 | , QSocketNotifier::Exception | ||||
80 | }; | ||||
81 | | ||||
82 | static const char * const qtscript_QSocketNotifier_Type_keys[] = { | ||||
83 | "Read" | ||||
84 | , "Write" | ||||
85 | , "Exception" | ||||
86 | }; | ||||
87 | | ||||
88 | static QString qtscript_QSocketNotifier_Type_toStringHelper(QSocketNotifier::Type value) | ||||
89 | { | ||||
90 | if ((value >= QSocketNotifier::Read) && (value <= QSocketNotifier::Exception)) | ||||
91 | return qtscript_QSocketNotifier_Type_keys[static_cast<int>(value)-static_cast<int>(QSocketNotifier::Read)]; | ||||
92 | return QString(); | ||||
93 | } | ||||
94 | | ||||
95 | static QScriptValue qtscript_QSocketNotifier_Type_toScriptValue(QScriptEngine *engine, const QSocketNotifier::Type &value) | ||||
96 | { | ||||
97 | QScriptValue clazz = engine->globalObject().property(QString::fromLatin1("QSocketNotifier")); | ||||
98 | return clazz.property(qtscript_QSocketNotifier_Type_toStringHelper(value)); | ||||
99 | } | ||||
100 | | ||||
101 | static void qtscript_QSocketNotifier_Type_fromScriptValue(const QScriptValue &value, QSocketNotifier::Type &out) | ||||
102 | { | ||||
103 | out = qvariant_cast<QSocketNotifier::Type>(value.toVariant()); | ||||
104 | } | ||||
105 | | ||||
106 | static QScriptValue qtscript_construct_QSocketNotifier_Type(QScriptContext *context, QScriptEngine *engine) | ||||
107 | { | ||||
108 | int arg = context->argument(0).toInt32(); | ||||
109 | if ((arg >= QSocketNotifier::Read) && (arg <= QSocketNotifier::Exception)) | ||||
110 | return qScriptValueFromValue(engine, static_cast<QSocketNotifier::Type>(arg)); | ||||
111 | return context->throwError(QString::fromLatin1("Type(): invalid enum value (%0)").arg(arg)); | ||||
112 | } | ||||
113 | | ||||
114 | static QScriptValue qtscript_QSocketNotifier_Type_valueOf(QScriptContext *context, QScriptEngine *engine) | ||||
115 | { | ||||
116 | QSocketNotifier::Type value = qscriptvalue_cast<QSocketNotifier::Type>(context->thisObject()); | ||||
117 | return QScriptValue(engine, static_cast<int>(value)); | ||||
118 | } | ||||
119 | | ||||
120 | static QScriptValue qtscript_QSocketNotifier_Type_toString(QScriptContext *context, QScriptEngine *engine) | ||||
121 | { | ||||
122 | QSocketNotifier::Type value = qscriptvalue_cast<QSocketNotifier::Type>(context->thisObject()); | ||||
123 | return QScriptValue(engine, qtscript_QSocketNotifier_Type_toStringHelper(value)); | ||||
124 | } | ||||
125 | | ||||
126 | static QScriptValue qtscript_create_QSocketNotifier_Type_class(QScriptEngine *engine, QScriptValue &clazz) | ||||
127 | { | ||||
128 | QScriptValue ctor = qtscript_create_enum_class_helper( | ||||
129 | engine, qtscript_construct_QSocketNotifier_Type, | ||||
130 | qtscript_QSocketNotifier_Type_valueOf, qtscript_QSocketNotifier_Type_toString); | ||||
131 | qScriptRegisterMetaType<QSocketNotifier::Type>(engine, qtscript_QSocketNotifier_Type_toScriptValue, | ||||
132 | qtscript_QSocketNotifier_Type_fromScriptValue, ctor.property(QString::fromLatin1("prototype"))); | ||||
133 | for (int i = 0; i < 3; ++i) { | ||||
134 | clazz.setProperty(QString::fromLatin1(qtscript_QSocketNotifier_Type_keys[i]), | ||||
135 | engine->newVariant(qVariantFromValue(qtscript_QSocketNotifier_Type_values[i])), | ||||
136 | QScriptValue::ReadOnly | QScriptValue::Undeletable); | ||||
137 | } | ||||
138 | return ctor; | ||||
139 | } | ||||
140 | | ||||
141 | // | ||||
142 | // QSocketNotifier | ||||
143 | // | ||||
144 | | ||||
145 | static QScriptValue qtscript_QSocketNotifier_prototype_call(QScriptContext *context, QScriptEngine *) | ||||
146 | { | ||||
147 | #if QT_VERSION > 0x040400 | ||||
148 | Q_ASSERT(context->callee().isFunction()); | ||||
149 | uint _id = context->callee().data().toUInt32(); | ||||
150 | #else | ||||
151 | uint _id; | ||||
152 | if (context->callee().isFunction()) | ||||
153 | _id = context->callee().data().toUInt32(); | ||||
154 | else | ||||
155 | _id = 0xBABE0000 + 2; | ||||
156 | #endif | ||||
157 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
158 | _id &= 0x0000FFFF; | ||||
159 | QSocketNotifier* _q_self = qscriptvalue_cast<QSocketNotifier*>(context->thisObject()); | ||||
160 | if (!_q_self) { | ||||
161 | return context->throwError(QScriptContext::TypeError, | ||||
162 | QString::fromLatin1("QSocketNotifier.%0(): this object is not a QSocketNotifier") | ||||
163 | .arg(qtscript_QSocketNotifier_function_names[_id+1])); | ||||
164 | } | ||||
165 | | ||||
166 | switch (_id) { | ||||
167 | case 0: | ||||
168 | if (context->argumentCount() == 0) { | ||||
169 | bool _q_result = _q_self->isEnabled(); | ||||
170 | return QScriptValue(context->engine(), _q_result); | ||||
171 | } | ||||
172 | break; | ||||
173 | | ||||
174 | case 1: | ||||
175 | if (context->argumentCount() == 0) { | ||||
176 | QSocketNotifier::Type _q_result = _q_self->type(); | ||||
177 | return qScriptValueFromValue(context->engine(), _q_result); | ||||
178 | } | ||||
179 | break; | ||||
180 | | ||||
181 | case 2: { | ||||
182 | QString result = QString::fromLatin1("QSocketNotifier"); | ||||
183 | return QScriptValue(context->engine(), result); | ||||
184 | } | ||||
185 | | ||||
186 | default: | ||||
187 | Q_ASSERT(false); | ||||
188 | } | ||||
189 | return qtscript_QSocketNotifier_throw_ambiguity_error_helper(context, | ||||
190 | qtscript_QSocketNotifier_function_names[_id+1], | ||||
191 | qtscript_QSocketNotifier_function_signatures[_id+1]); | ||||
192 | } | ||||
193 | | ||||
194 | static QScriptValue qtscript_QSocketNotifier_static_call(QScriptContext *context, QScriptEngine *) | ||||
195 | { | ||||
196 | uint _id = context->callee().data().toUInt32(); | ||||
197 | Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000); | ||||
198 | _id &= 0x0000FFFF; | ||||
199 | switch (_id) { | ||||
200 | case 0: | ||||
201 | return context->throwError(QScriptContext::TypeError, | ||||
202 | QString::fromLatin1("QSocketNotifier cannot be constructed")); | ||||
203 | break; | ||||
204 | | ||||
205 | default: | ||||
206 | Q_ASSERT(false); | ||||
207 | } | ||||
208 | return qtscript_QSocketNotifier_throw_ambiguity_error_helper(context, | ||||
209 | qtscript_QSocketNotifier_function_names[_id], | ||||
210 | qtscript_QSocketNotifier_function_signatures[_id]); | ||||
211 | } | ||||
212 | | ||||
213 | static QScriptValue qtscript_QSocketNotifier_toScriptValue(QScriptEngine *engine, QSocketNotifier* const &in) | ||||
214 | { | ||||
215 | return engine->newQObject(in, QScriptEngine::QtOwnership, QScriptEngine::PreferExistingWrapperObject); | ||||
216 | } | ||||
217 | | ||||
218 | static void qtscript_QSocketNotifier_fromScriptValue(const QScriptValue &value, QSocketNotifier* &out) | ||||
219 | { | ||||
220 | out = qobject_cast<QSocketNotifier*>(value.toQObject()); | ||||
221 | } | ||||
222 | | ||||
223 | QScriptValue qtscript_create_QSocketNotifier_class(QScriptEngine *engine) | ||||
224 | { | ||||
225 | engine->setDefaultPrototype(qMetaTypeId<QSocketNotifier*>(), QScriptValue()); | ||||
226 | QScriptValue proto = engine->newVariant(qVariantFromValue((QSocketNotifier*)0)); | ||||
227 | proto.setPrototype(engine->defaultPrototype(qMetaTypeId<QObject*>())); | ||||
228 | for (int i = 0; i < 3; ++i) { | ||||
229 | QScriptValue fun = engine->newFunction(qtscript_QSocketNotifier_prototype_call, qtscript_QSocketNotifier_function_lengths[i+1]); | ||||
230 | fun.setData(QScriptValue(engine, uint(0xBABE0000 + i))); | ||||
231 | proto.setProperty(QString::fromLatin1(qtscript_QSocketNotifier_function_names[i+1]), | ||||
232 | fun, QScriptValue::SkipInEnumeration); | ||||
233 | } | ||||
234 | | ||||
235 | qScriptRegisterMetaType<QSocketNotifier*>(engine, qtscript_QSocketNotifier_toScriptValue, | ||||
236 | qtscript_QSocketNotifier_fromScriptValue, proto); | ||||
237 | | ||||
238 | QScriptValue ctor = engine->newFunction(qtscript_QSocketNotifier_static_call, proto, qtscript_QSocketNotifier_function_lengths[0]); | ||||
239 | ctor.setData(QScriptValue(engine, uint(0xBABE0000 + 0))); | ||||
240 | | ||||
241 | ctor.setProperty(QString::fromLatin1("Type"), | ||||
242 | qtscript_create_QSocketNotifier_Type_class(engine, ctor)); | ||||
243 | return ctor; | ||||
244 | } |