qtbindings 4.8.3.0 → 4.8.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +1 -2
- data/bin/rbrcc +5 -5
- data/bin/rbuic4 +5 -5
- data/bin/smokeapi +5 -5
- data/bin/smokedeptool +5 -5
- data/{CHANGELOG.txt → changelog.txt} +15 -0
- data/examples/desktop/screenshot/screenshot.rb +10 -9
- data/ext/cmake/modules/FindRuby.cmake +1 -1
- data/ext/ruby/qtruby/src/handlers.cpp +186 -176
- data/ext/ruby/qtruby/src/{Qt.cpp → qt.cpp} +135 -114
- data/ext/ruby/qtruby/src/qtruby.cpp +4 -1
- data/extconf.rb +20 -12
- data/{KNOWN_ISSUES.txt → known_issues.txt} +0 -2
- data/lib/Qt/qtruby4.rb +261 -237
- data/lib/qt4.rb +101 -0
- data/lib/qtbindings_version.rb +2 -2
- data/qtbindings.gemspec +1 -1
- data/qtbindingsnative.gemspec +1 -1
- data/{README.txt → readme.txt} +127 -119
- data/{TODO.txt → todo.txt} +0 -1
- metadata +13 -14
- data/lib/Qt4.rb +0 -20
@@ -21,28 +21,29 @@
|
|
21
21
|
#include <stdio.h>
|
22
22
|
#include <stdarg.h>
|
23
23
|
|
24
|
-
#include <QtCore/qabstractitemmodel.h>
|
24
|
+
#include <QtCore/qabstractitemmodel.h>
|
25
25
|
#include <QtCore/qglobal.h>
|
26
26
|
#include <QtCore/qhash.h>
|
27
|
-
#include <QtCore/qline.h>
|
27
|
+
#include <QtCore/qline.h>
|
28
28
|
#include <QtCore/qmetaobject.h>
|
29
29
|
#include <QtCore/qobject.h>
|
30
|
-
#include <QtCore/qrect.h>
|
30
|
+
#include <QtCore/qrect.h>
|
31
31
|
#include <QtCore/qregexp.h>
|
32
32
|
#include <QtCore/qstring.h>
|
33
33
|
#include <QtCore/qvariant.h>
|
34
|
+
#include <QtCore/qmutex.h>
|
34
35
|
#include <QtGui/qapplication.h>
|
35
|
-
#include <QtGui/qbitmap.h>
|
36
|
-
#include <QtGui/qcolor.h>
|
36
|
+
#include <QtGui/qbitmap.h>
|
37
|
+
#include <QtGui/qcolor.h>
|
37
38
|
#include <QtGui/qcursor.h>
|
38
|
-
#include <QtGui/qfont.h>
|
39
|
-
#include <QtGui/qicon.h>
|
39
|
+
#include <QtGui/qfont.h>
|
40
|
+
#include <QtGui/qicon.h>
|
40
41
|
#include <QtGui/qitemselectionmodel.h>
|
41
|
-
#include <QtGui/qpalette.h>
|
42
|
-
#include <QtGui/qpen.h>
|
43
|
-
#include <QtGui/qpixmap.h>
|
44
|
-
#include <QtGui/qpolygon.h>
|
45
|
-
#include <QtGui/qtextformat.h>
|
42
|
+
#include <QtGui/qpalette.h>
|
43
|
+
#include <QtGui/qpen.h>
|
44
|
+
#include <QtGui/qpixmap.h>
|
45
|
+
#include <QtGui/qpolygon.h>
|
46
|
+
#include <QtGui/qtextformat.h>
|
46
47
|
#include <QtGui/qwidget.h>
|
47
48
|
|
48
49
|
#ifdef QT_QTDBUS
|
@@ -100,6 +101,7 @@ int do_debug = qtdb_none;
|
|
100
101
|
#endif
|
101
102
|
|
102
103
|
typedef QHash<void *, SmokeValue> PointerMap;
|
104
|
+
static QMutex pointer_map_mutex;
|
103
105
|
Q_GLOBAL_STATIC(PointerMap, pointer_map)
|
104
106
|
int object_count = 0;
|
105
107
|
|
@@ -114,7 +116,7 @@ QHash<Smoke::ModuleIndex, QByteArray*> IdToClassNameMap;
|
|
114
116
|
|
115
117
|
Smoke::ModuleIndex _current_method;
|
116
118
|
|
117
|
-
smokeruby_object *
|
119
|
+
smokeruby_object *
|
118
120
|
alloc_smokeruby_object(bool allocated, Smoke * smoke, int classId, void * ptr)
|
119
121
|
{
|
120
122
|
smokeruby_object * o = ALLOC(smokeruby_object);
|
@@ -153,6 +155,8 @@ VALUE getPointerObject(void *ptr) {
|
|
153
155
|
}
|
154
156
|
|
155
157
|
SmokeValue getSmokeValue(void *ptr) {
|
158
|
+
pointer_map_mutex.lock();
|
159
|
+
|
156
160
|
if (!pointer_map() || !pointer_map()->contains(ptr)) {
|
157
161
|
if (do_debug & qtdb_gc) {
|
158
162
|
qWarning("getPointerObject %p -> nil", ptr);
|
@@ -160,23 +164,26 @@ SmokeValue getSmokeValue(void *ptr) {
|
|
160
164
|
qWarning("getPointerObject pointer_map deleted");
|
161
165
|
}
|
162
166
|
}
|
167
|
+
pointer_map_mutex.unlock();
|
163
168
|
return SmokeValue();
|
164
169
|
} else {
|
165
170
|
if (do_debug & qtdb_gc) {
|
166
171
|
qWarning("getPointerObject %p -> %p", ptr, (void *) pointer_map()->operator[](ptr).value);
|
167
172
|
}
|
173
|
+
pointer_map_mutex.unlock();
|
168
174
|
return pointer_map()->operator[](ptr);
|
169
175
|
}
|
170
176
|
}
|
171
177
|
|
172
178
|
void unmapPointer(void *ptr, Smoke *smoke, Smoke::Index fromClassId, Smoke::Index toClassId, void *lastptr) {
|
179
|
+
pointer_map_mutex.lock();
|
173
180
|
ptr = smoke->cast(ptr, fromClassId, toClassId);
|
174
181
|
|
175
182
|
if (ptr != lastptr) {
|
176
183
|
lastptr = ptr;
|
177
184
|
if (pointer_map() && pointer_map()->contains(ptr)) {
|
178
185
|
VALUE obj_ptr = pointer_map()->operator[](ptr).value;
|
179
|
-
|
186
|
+
|
180
187
|
if (do_debug & qtdb_gc) {
|
181
188
|
const char *className = smoke->classes[fromClassId].className;
|
182
189
|
qWarning("unmapPointer (%s*)%p -> %p size: %d", className, ptr, (void*)(&obj_ptr), pointer_map()->size() - 1);
|
@@ -195,9 +202,11 @@ void unmapPointer(void *ptr, Smoke *smoke, Smoke::Index fromClassId, Smoke::Inde
|
|
195
202
|
toClassId = mi.index;
|
196
203
|
}
|
197
204
|
|
205
|
+
pointer_map_mutex.unlock();
|
198
206
|
for (Smoke::Index *i = smoke->inheritanceList + smoke->classes[toClassId].parents; *i; i++) {
|
199
207
|
unmapPointer(ptr, smoke, toClassId, *i, lastptr);
|
200
208
|
}
|
209
|
+
|
201
210
|
}
|
202
211
|
|
203
212
|
void unmapPointer(smokeruby_object *o, Smoke::Index classId, void *lastptr) {
|
@@ -208,16 +217,18 @@ void unmapPointer(smokeruby_object *o, Smoke::Index classId, void *lastptr) {
|
|
208
217
|
// Recurse to store it also as casted to its parent classes.
|
209
218
|
|
210
219
|
void mapPointer(VALUE obj, smokeruby_object* o, void *ptr, Smoke *smoke, Smoke::Index fromClassId, Smoke::Index toClassId, void *lastptr) {
|
220
|
+
pointer_map_mutex.unlock();
|
221
|
+
|
211
222
|
ptr = smoke->cast(ptr, fromClassId, toClassId);
|
212
223
|
|
213
224
|
if (ptr != lastptr) {
|
214
225
|
lastptr = ptr;
|
215
|
-
|
226
|
+
|
216
227
|
if (do_debug & qtdb_gc) {
|
217
228
|
const char *className = smoke->classes[fromClassId].className;
|
218
229
|
qWarning("mapPointer (%s*)%p -> %p size: %d", className, ptr, (void*)obj, pointer_map()->size() + 1);
|
219
230
|
}
|
220
|
-
|
231
|
+
|
221
232
|
SmokeValue value(obj, o);
|
222
233
|
pointer_map()->insert(ptr, value);
|
223
234
|
}
|
@@ -231,10 +242,11 @@ void mapPointer(VALUE obj, smokeruby_object* o, void *ptr, Smoke *smoke, Smoke::
|
|
231
242
|
toClassId = mi.index;
|
232
243
|
}
|
233
244
|
|
245
|
+
pointer_map_mutex.unlock();
|
234
246
|
for (Smoke::Index *i = smoke->inheritanceList + smoke->classes[toClassId].parents; *i; i++) {
|
235
247
|
mapPointer(obj, o, ptr, smoke, toClassId, *i, lastptr);
|
236
248
|
}
|
237
|
-
|
249
|
+
|
238
250
|
return;
|
239
251
|
}
|
240
252
|
|
@@ -282,7 +294,7 @@ Binding::callMethod(Smoke::Index method, void *ptr, Smoke::Stack args, bool /*is
|
|
282
294
|
if (meth.flags & Smoke::mf_const) {
|
283
295
|
signature += " const";
|
284
296
|
}
|
285
|
-
qWarning( "module: %s virtual %p->%s::%s called",
|
297
|
+
qWarning( "module: %s virtual %p->%s::%s called",
|
286
298
|
smoke->moduleName(),
|
287
299
|
ptr,
|
288
300
|
smoke->classes[smoke->methods[method].classId].className,
|
@@ -298,12 +310,21 @@ Binding::callMethod(Smoke::Index method, void *ptr, Smoke::Stack args, bool /*is
|
|
298
310
|
if (qstrncmp(methodName, "operator", sizeof("operator") - 1) == 0) {
|
299
311
|
methodName += (sizeof("operator") - 1);
|
300
312
|
}
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
313
|
+
|
314
|
+
// If not in a ruby thread, just call the C++ version
|
315
|
+
// During GC, avoid checking for override and just call the C++ version
|
316
|
+
// If the virtual method hasn't been overriden, just call the C++ one.
|
317
|
+
#ifdef HAVE_RUBY_RUBY_H
|
318
|
+
int ruby_thread = ruby_native_thread_p();
|
319
|
+
if ((ruby_thread == 0) || rb_during_gc() || rb_respond_to(obj, rb_intern(methodName)) == 0) {
|
320
|
+
return false;
|
306
321
|
}
|
322
|
+
#else
|
323
|
+
if (rb_during_gc() || ruby_stack_check() || rb_respond_to(obj, rb_intern(methodName)) == 0) {
|
324
|
+
return false;
|
325
|
+
}
|
326
|
+
#endif
|
327
|
+
|
307
328
|
QtRuby::VirtualMethodCall c(smoke, method, args, obj, ALLOCA_N(VALUE, smoke->methods[method].numArgs));
|
308
329
|
c.next();
|
309
330
|
return true;
|
@@ -316,7 +337,7 @@ Binding::className(Smoke::Index classId) {
|
|
316
337
|
}
|
317
338
|
|
318
339
|
/*
|
319
|
-
Converts a C++ value returned by a signal invocation to a Ruby
|
340
|
+
Converts a C++ value returned by a signal invocation to a Ruby
|
320
341
|
reply type
|
321
342
|
*/
|
322
343
|
class SignalReturnValue : public Marshall {
|
@@ -324,7 +345,7 @@ class SignalReturnValue : public Marshall {
|
|
324
345
|
Smoke::Stack _stack;
|
325
346
|
VALUE * _result;
|
326
347
|
public:
|
327
|
-
SignalReturnValue(void ** o, VALUE * result, QList<MocArgument*> replyType)
|
348
|
+
SignalReturnValue(void ** o, VALUE * result, QList<MocArgument*> replyType)
|
328
349
|
{
|
329
350
|
_result = result;
|
330
351
|
_replyType = replyType;
|
@@ -334,25 +355,25 @@ public:
|
|
334
355
|
(*fn)(this);
|
335
356
|
}
|
336
357
|
|
337
|
-
SmokeType type() {
|
338
|
-
return _replyType[0]->st;
|
358
|
+
SmokeType type() {
|
359
|
+
return _replyType[0]->st;
|
339
360
|
}
|
340
361
|
Marshall::Action action() { return Marshall::ToVALUE; }
|
341
362
|
Smoke::StackItem &item() { return _stack[0]; }
|
342
363
|
VALUE * var() {
|
343
364
|
return _result;
|
344
365
|
}
|
345
|
-
|
346
|
-
void unsupported()
|
366
|
+
|
367
|
+
void unsupported()
|
347
368
|
{
|
348
369
|
rb_raise(rb_eArgError, "Cannot handle '%s' as signal reply-type", type().name());
|
349
370
|
}
|
350
371
|
Smoke *smoke() { return type().smoke(); }
|
351
|
-
|
372
|
+
|
352
373
|
void next() {}
|
353
|
-
|
374
|
+
|
354
375
|
bool cleanup() { return false; }
|
355
|
-
|
376
|
+
|
356
377
|
~SignalReturnValue() {
|
357
378
|
delete[] _stack;
|
358
379
|
}
|
@@ -364,31 +385,31 @@ public:
|
|
364
385
|
*/
|
365
386
|
EmitSignal::EmitSignal(QObject *obj, int id, int /*items*/, QList<MocArgument*> args, VALUE *sp, VALUE * result) : SigSlotBase(args),
|
366
387
|
_obj(obj), _id(id)
|
367
|
-
{
|
388
|
+
{
|
368
389
|
_sp = sp;
|
369
390
|
_result = result;
|
370
391
|
}
|
371
392
|
|
372
|
-
Marshall::Action
|
373
|
-
EmitSignal::action()
|
374
|
-
{
|
375
|
-
return Marshall::FromVALUE;
|
393
|
+
Marshall::Action
|
394
|
+
EmitSignal::action()
|
395
|
+
{
|
396
|
+
return Marshall::FromVALUE;
|
376
397
|
}
|
377
398
|
|
378
399
|
Smoke::StackItem &
|
379
|
-
EmitSignal::item()
|
380
|
-
{
|
381
|
-
return _stack[_cur];
|
400
|
+
EmitSignal::item()
|
401
|
+
{
|
402
|
+
return _stack[_cur];
|
382
403
|
}
|
383
404
|
|
384
405
|
const char *
|
385
|
-
EmitSignal::mytype()
|
386
|
-
{
|
387
|
-
return "signal";
|
406
|
+
EmitSignal::mytype()
|
407
|
+
{
|
408
|
+
return "signal";
|
388
409
|
}
|
389
410
|
|
390
|
-
void
|
391
|
-
EmitSignal::emitSignal()
|
411
|
+
void
|
412
|
+
EmitSignal::emitSignal()
|
392
413
|
{
|
393
414
|
if (_called) return;
|
394
415
|
_called = true;
|
@@ -406,45 +427,45 @@ EmitSignal::emitSignal()
|
|
406
427
|
delete[] o;
|
407
428
|
}
|
408
429
|
|
409
|
-
void
|
410
|
-
EmitSignal::mainfunction()
|
411
|
-
{
|
412
|
-
emitSignal();
|
430
|
+
void
|
431
|
+
EmitSignal::mainfunction()
|
432
|
+
{
|
433
|
+
emitSignal();
|
413
434
|
}
|
414
435
|
|
415
|
-
bool
|
416
|
-
EmitSignal::cleanup()
|
417
|
-
{
|
418
|
-
return true;
|
436
|
+
bool
|
437
|
+
EmitSignal::cleanup()
|
438
|
+
{
|
439
|
+
return true;
|
419
440
|
}
|
420
441
|
|
421
442
|
InvokeNativeSlot::InvokeNativeSlot(QObject *obj, int id, int /*items*/, QList<MocArgument*> args, VALUE *sp, VALUE * result) : SigSlotBase(args),
|
422
443
|
_obj(obj), _id(id)
|
423
|
-
{
|
444
|
+
{
|
424
445
|
_sp = sp;
|
425
446
|
_result = result;
|
426
447
|
}
|
427
448
|
|
428
|
-
Marshall::Action
|
429
|
-
InvokeNativeSlot::action()
|
430
|
-
{
|
431
|
-
return Marshall::FromVALUE;
|
449
|
+
Marshall::Action
|
450
|
+
InvokeNativeSlot::action()
|
451
|
+
{
|
452
|
+
return Marshall::FromVALUE;
|
432
453
|
}
|
433
454
|
|
434
455
|
Smoke::StackItem &
|
435
|
-
InvokeNativeSlot::item()
|
436
|
-
{
|
437
|
-
return _stack[_cur];
|
456
|
+
InvokeNativeSlot::item()
|
457
|
+
{
|
458
|
+
return _stack[_cur];
|
438
459
|
}
|
439
460
|
|
440
461
|
const char *
|
441
|
-
InvokeNativeSlot::mytype()
|
442
|
-
{
|
443
|
-
return "slot";
|
462
|
+
InvokeNativeSlot::mytype()
|
463
|
+
{
|
464
|
+
return "slot";
|
444
465
|
}
|
445
466
|
|
446
|
-
void
|
447
|
-
InvokeNativeSlot::invokeSlot()
|
467
|
+
void
|
468
|
+
InvokeNativeSlot::invokeSlot()
|
448
469
|
{
|
449
470
|
if (_called) return;
|
450
471
|
_called = true;
|
@@ -455,28 +476,28 @@ InvokeNativeSlot::invokeSlot()
|
|
455
476
|
prepareReturnValue(o);
|
456
477
|
|
457
478
|
_obj->qt_metacall(QMetaObject::InvokeMetaMethod, _id, o);
|
458
|
-
|
479
|
+
|
459
480
|
if (_args[0]->argType != xmoc_void) {
|
460
481
|
SignalReturnValue r(o, _result, _args);
|
461
482
|
}
|
462
483
|
delete[] o;
|
463
484
|
}
|
464
485
|
|
465
|
-
void
|
466
|
-
InvokeNativeSlot::mainfunction()
|
467
|
-
{
|
468
|
-
invokeSlot();
|
486
|
+
void
|
487
|
+
InvokeNativeSlot::mainfunction()
|
488
|
+
{
|
489
|
+
invokeSlot();
|
469
490
|
}
|
470
491
|
|
471
|
-
bool
|
472
|
-
InvokeNativeSlot::cleanup()
|
473
|
-
{
|
474
|
-
return true;
|
492
|
+
bool
|
493
|
+
InvokeNativeSlot::cleanup()
|
494
|
+
{
|
495
|
+
return true;
|
475
496
|
}
|
476
497
|
|
477
498
|
}
|
478
499
|
|
479
|
-
VALUE rb_str_catf(VALUE self, const char *format, ...)
|
500
|
+
VALUE rb_str_catf(VALUE self, const char *format, ...)
|
480
501
|
{
|
481
502
|
#define CAT_BUFFER_SIZE 2048
|
482
503
|
static char p[CAT_BUFFER_SIZE];
|
@@ -525,7 +546,7 @@ findMethod(VALUE /*self*/, VALUE c_value, VALUE name_value)
|
|
525
546
|
char *c = StringValuePtr(c_value);
|
526
547
|
char *name = StringValuePtr(name_value);
|
527
548
|
VALUE result = rb_ary_new();
|
528
|
-
Smoke::ModuleIndex classId = Smoke::findClass(c);
|
549
|
+
Smoke::ModuleIndex classId = Smoke::findClass(c);
|
529
550
|
Smoke::ModuleIndex meth = Smoke::NullModuleIndex;
|
530
551
|
QList<Smoke::ModuleIndex> milist;
|
531
552
|
if (classId.smoke != 0) {
|
@@ -557,7 +578,7 @@ findMethod(VALUE /*self*/, VALUE c_value, VALUE name_value)
|
|
557
578
|
return result;
|
558
579
|
// empty list
|
559
580
|
} else {
|
560
|
-
foreach (Smoke::ModuleIndex meth, milist) {
|
581
|
+
foreach (Smoke::ModuleIndex meth, milist) {
|
561
582
|
if (meth.index > 0) {
|
562
583
|
Smoke::Index i = meth.smoke->methodMaps[meth.index].method;
|
563
584
|
if (i == 0) { // shouldn't happen
|
@@ -695,7 +716,7 @@ findAllMethods(int argc, VALUE * argv, VALUE /*self*/)
|
|
695
716
|
rb_ary_push(result, rb_str_new2(s->methodNames[methodRef.name])); \
|
696
717
|
} \
|
697
718
|
}
|
698
|
-
|
719
|
+
|
699
720
|
VALUE
|
700
721
|
findAllMethodNames(VALUE /*self*/, VALUE result, VALUE classid, VALUE flags_value)
|
701
722
|
{
|
@@ -779,7 +800,7 @@ static QByteArray * mcid = 0;
|
|
779
800
|
#ifdef DEBUG
|
780
801
|
if (do_debug & qtdb_calls) qWarning("method_missing mcid: %s", (const char *) *mcid);
|
781
802
|
#endif
|
782
|
-
|
803
|
+
|
783
804
|
if (rcid) {
|
784
805
|
// Got a hit
|
785
806
|
#ifdef DEBUG
|
@@ -791,7 +812,7 @@ static QByteArray * mcid = 0;
|
|
791
812
|
_current_method.smoke = 0;
|
792
813
|
_current_method.index = -1;
|
793
814
|
}
|
794
|
-
|
815
|
+
|
795
816
|
return mcid;
|
796
817
|
}
|
797
818
|
|
@@ -808,31 +829,31 @@ static QByteArray * pred = 0;
|
|
808
829
|
if (pred == 0) {
|
809
830
|
pred = new QByteArray();
|
810
831
|
}
|
811
|
-
|
832
|
+
|
812
833
|
*pred = methodName;
|
813
834
|
if (pred->endsWith("?")) {
|
814
835
|
smokeruby_object *o = value_obj_info(self);
|
815
836
|
if(!o || !o->ptr) {
|
816
837
|
return rb_call_super(argc, argv);
|
817
838
|
}
|
818
|
-
|
839
|
+
|
819
840
|
// Drop the trailing '?'
|
820
841
|
pred->replace(pred->length() - 1, 1, "");
|
821
|
-
|
842
|
+
|
822
843
|
pred->replace(0, 1, pred->mid(0, 1).toUpper());
|
823
844
|
pred->replace(0, 0, "is");
|
824
845
|
Smoke::ModuleIndex meth = o->smoke->findMethod(o->smoke->classes[o->classId].className, (const char *) *pred);
|
825
|
-
|
846
|
+
|
826
847
|
if (meth.index == 0) {
|
827
848
|
pred->replace(0, 2, "has");
|
828
849
|
meth = o->smoke->findMethod(o->smoke->classes[o->classId].className, *pred);
|
829
850
|
}
|
830
|
-
|
851
|
+
|
831
852
|
if (meth.index > 0) {
|
832
853
|
methodName = (char *) (const char *) *pred;
|
833
854
|
}
|
834
855
|
}
|
835
|
-
|
856
|
+
|
836
857
|
VALUE * temp_stack = ALLOCA_N(VALUE, argc+3);
|
837
858
|
temp_stack[0] = rb_str_new2("Qt");
|
838
859
|
temp_stack[1] = rb_str_new2(methodName);
|
@@ -870,8 +891,8 @@ static QByteArray * pred = 0;
|
|
870
891
|
// Check for property getter/setter calls, and for slots in QObject classes
|
871
892
|
// not in the smoke library
|
872
893
|
smokeruby_object *o = value_obj_info(self);
|
873
|
-
if ( o != 0
|
874
|
-
&& o->ptr != 0
|
894
|
+
if ( o != 0
|
895
|
+
&& o->ptr != 0
|
875
896
|
&& Smoke::isDerivedFrom(Smoke::ModuleIndex(o->smoke, o->classId), Smoke::findClass("QObject")) )
|
876
897
|
{
|
877
898
|
QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
|
@@ -879,7 +900,7 @@ static QByteArray * name = 0;
|
|
879
900
|
if (name == 0) {
|
880
901
|
name = new QByteArray();
|
881
902
|
}
|
882
|
-
|
903
|
+
|
883
904
|
*name = rb_id2name(SYM2ID(argv[0]));
|
884
905
|
const QMetaObject * meta = qobject->metaObject();
|
885
906
|
|
@@ -911,9 +932,9 @@ static QByteArray * name = 0;
|
|
911
932
|
// The class isn't in the Smoke lib. But if it is called 'local::Merged'
|
912
933
|
// it is from a QDBusInterface and the slots are remote, so don't try to
|
913
934
|
// those.
|
914
|
-
while ( classId == 0
|
935
|
+
while ( classId == 0
|
915
936
|
&& qstrcmp(meta->className(), "local::Merged") != 0
|
916
|
-
&& qstrcmp(meta->superClass()->className(), "QDBusAbstractInterface") != 0 )
|
937
|
+
&& qstrcmp(meta->superClass()->className(), "QDBusAbstractInterface") != 0 )
|
917
938
|
{
|
918
939
|
// Assume the QObject has slots which aren't in the Smoke library, so try
|
919
940
|
// and call the slot directly
|
@@ -925,7 +946,7 @@ static QByteArray * name = 0;
|
|
925
946
|
// Don't check that the types of the ruby args match the c++ ones for now,
|
926
947
|
// only that the name and arg count is the same.
|
927
948
|
if (*name == methodName && meta->method(id).parameterTypes().count() == (argc - 1)) {
|
928
|
-
QList<MocArgument*> args = get_moc_arguments( o->smoke, meta->method(id).typeName(),
|
949
|
+
QList<MocArgument*> args = get_moc_arguments( o->smoke, meta->method(id).typeName(),
|
929
950
|
meta->method(id).parameterTypes() );
|
930
951
|
VALUE result = Qnil;
|
931
952
|
QtRuby::InvokeNativeSlot slot(qobject, id, argc - 1, args, argv + 1, &result);
|
@@ -938,7 +959,7 @@ static QByteArray * name = 0;
|
|
938
959
|
classId = o->smoke->idClass(meta->className()).index;
|
939
960
|
}
|
940
961
|
}
|
941
|
-
|
962
|
+
|
942
963
|
return rb_call_super(argc, argv);
|
943
964
|
}
|
944
965
|
}
|
@@ -984,10 +1005,10 @@ static QRegExp * rx = 0;
|
|
984
1005
|
if (rx == 0) {
|
985
1006
|
rx = new QRegExp("[a-zA-Z]+");
|
986
1007
|
}
|
987
|
-
|
1008
|
+
|
988
1009
|
if (rx->indexIn(methodName) == -1) {
|
989
1010
|
// If an operator method hasn't been found as an instance method,
|
990
|
-
// then look for a class method - after 'op(self,a)' try 'self.op(a)'
|
1011
|
+
// then look for a class method - after 'op(self,a)' try 'self.op(a)'
|
991
1012
|
VALUE * method_stack = ALLOCA_N(VALUE, argc - 1);
|
992
1013
|
method_stack[0] = argv[0];
|
993
1014
|
for (int count = 1; count < argc - 1; count++) {
|
@@ -1036,7 +1057,7 @@ static QRegExp * rx = 0;
|
|
1036
1057
|
typeId = smoke->idType(targetType.constData());
|
1037
1058
|
}
|
1038
1059
|
|
1039
|
-
// This shouldn't be necessary because the type of the slot arg should always be in the
|
1060
|
+
// This shouldn't be necessary because the type of the slot arg should always be in the
|
1040
1061
|
// smoke module of the slot being invoked. However, that isn't true for a dataUpdated()
|
1041
1062
|
// slot in a PlasmaScripting::Applet
|
1042
1063
|
if (typeId == 0) {
|
@@ -1048,20 +1069,20 @@ static QRegExp * rx = 0;
|
|
1048
1069
|
if (typeId != 0) {
|
1049
1070
|
break;
|
1050
1071
|
}
|
1051
|
-
|
1072
|
+
|
1052
1073
|
if (typeId == 0 && !name.contains('*')) {
|
1053
1074
|
if (!name.contains("&")) {
|
1054
1075
|
targetType += "&";
|
1055
1076
|
}
|
1056
1077
|
|
1057
1078
|
typeId = smoke->idType(targetType.constData());
|
1058
|
-
|
1079
|
+
|
1059
1080
|
if (typeId != 0) {
|
1060
1081
|
break;
|
1061
1082
|
}
|
1062
1083
|
}
|
1063
1084
|
}
|
1064
|
-
}
|
1085
|
+
}
|
1065
1086
|
} else if (staticType == "bool") {
|
1066
1087
|
arg->argType = xmoc_bool;
|
1067
1088
|
smoke = qtcore_Smoke;
|
@@ -1139,9 +1160,9 @@ qobject_metaobject(VALUE self)
|
|
1139
1160
|
return obj;
|
1140
1161
|
}
|
1141
1162
|
|
1142
|
-
smokeruby_object * m = alloc_smokeruby_object( false,
|
1143
|
-
o->smoke,
|
1144
|
-
o->smoke->idClass("QMetaObject").index,
|
1163
|
+
smokeruby_object * m = alloc_smokeruby_object( false,
|
1164
|
+
o->smoke,
|
1165
|
+
o->smoke->idClass("QMetaObject").index,
|
1145
1166
|
meta );
|
1146
1167
|
|
1147
1168
|
obj = set_obj_info("Qt::MetaObject", m);
|
@@ -1165,8 +1186,8 @@ set_obj_info(const char * className, smokeruby_object * o)
|
|
1165
1186
|
}
|
1166
1187
|
// If the instance is a subclass of QObject, then check to see if the
|
1167
1188
|
// className from its QMetaObject is in the Smoke library. If not then
|
1168
|
-
// create a Ruby class for it dynamically. Remove the first letter from
|
1169
|
-
// any class names beginning with 'Q' or 'K' and put them under the Qt::
|
1189
|
+
// create a Ruby class for it dynamically. Remove the first letter from
|
1190
|
+
// any class names beginning with 'Q' or 'K' and put them under the Qt::
|
1170
1191
|
// or KDE:: modules respectively.
|
1171
1192
|
if (o->smoke->isDerivedFrom(o->smoke, o->classId, o->smoke->idClass("QObject").smoke, o->smoke->idClass("QObject").index)) {
|
1172
1193
|
QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
|
@@ -1197,8 +1218,8 @@ set_obj_info(const char * className, smokeruby_object * o)
|
|
1197
1218
|
// add them
|
1198
1219
|
if (qstrcmp(meta->className(), meta->enumerator(id).scope()) == 0) {
|
1199
1220
|
for (int i = 0; i < meta->enumerator(id).keyCount(); i++) {
|
1200
|
-
rb_define_const( klass,
|
1201
|
-
meta->enumerator(id).key(i),
|
1221
|
+
rb_define_const( klass,
|
1222
|
+
meta->enumerator(id).key(i),
|
1202
1223
|
INT2NUM(meta->enumerator(id).value(i)) );
|
1203
1224
|
}
|
1204
1225
|
}
|
@@ -1206,7 +1227,7 @@ set_obj_info(const char * className, smokeruby_object * o)
|
|
1206
1227
|
}
|
1207
1228
|
|
1208
1229
|
// Add a Qt::Object.metaObject method which will do dynamic despatch on the
|
1209
|
-
// metaObject() virtual method so that the true QMetaObject of the class
|
1230
|
+
// metaObject() virtual method so that the true QMetaObject of the class
|
1210
1231
|
// is returned, rather than for the one for the parent class that is in
|
1211
1232
|
// the Smoke library.
|
1212
1233
|
rb_define_method(klass, "metaObject", (VALUE (*) (...)) qobject_metaobject, 0);
|
@@ -1217,21 +1238,21 @@ set_obj_info(const char * className, smokeruby_object * o)
|
|
1217
1238
|
return obj;
|
1218
1239
|
}
|
1219
1240
|
|
1220
|
-
VALUE
|
1241
|
+
VALUE
|
1221
1242
|
kross2smoke(VALUE /*self*/, VALUE krobject, VALUE new_klass)
|
1222
1243
|
{
|
1223
1244
|
VALUE new_klassname = rb_funcall(new_klass, rb_intern("name"), 0);
|
1224
|
-
|
1245
|
+
|
1225
1246
|
Smoke::ModuleIndex * cast_to_id = classcache.value(StringValuePtr(new_klassname));
|
1226
1247
|
if (cast_to_id == 0) {
|
1227
1248
|
rb_raise(rb_eArgError, "unable to find class \"%s\" to cast to\n", StringValuePtr(new_klassname));
|
1228
1249
|
}
|
1229
|
-
|
1250
|
+
|
1230
1251
|
void* o;
|
1231
1252
|
Data_Get_Struct(krobject, void, o);
|
1232
|
-
|
1253
|
+
|
1233
1254
|
smokeruby_object * o_cast = alloc_smokeruby_object(false, cast_to_id->smoke, (int) cast_to_id->index, o);
|
1234
|
-
|
1255
|
+
|
1235
1256
|
VALUE obj = Data_Wrap_Struct(new_klass, smokeruby_mark, smokeruby_free, (void *) o_cast);
|
1236
1257
|
mapPointer(obj, o_cast, o_cast->classId, 0);
|
1237
1258
|
return obj;
|
@@ -1269,7 +1290,7 @@ value_to_type_flag(VALUE ruby_value)
|
|
1269
1290
|
return r;
|
1270
1291
|
}
|
1271
1292
|
|
1272
|
-
VALUE prettyPrintMethod(Smoke::Index id)
|
1293
|
+
VALUE prettyPrintMethod(Smoke::Index id)
|
1273
1294
|
{
|
1274
1295
|
VALUE r = rb_str_new2("");
|
1275
1296
|
const Smoke::Method &meth = qtcore_Smoke->methods[id];
|