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