1 /***************************************************************************
2 qtruby.cpp - description
5 copyright : (C) 2003-2006 by Richard Dale
6 email : Richard_Dale@tipitina.demon.co.uk
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU Lesser General Public License as *
13 * published by the Free Software Foundation; either version 2 of the *
14 * License, or (at your option) any later version. *
16 ***************************************************************************/
18 #include <QtCore/qabstractitemmodel.h>
19 #include <QtCore/qglobal.h>
20 #include <QtCore/qhash.h>
21 #include <QtCore/qline.h>
22 #include <QtCore/qmetaobject.h>
23 #include <QtCore/qobject.h>
24 #include <QtCore/qrect.h>
25 #include <QtCore/qregexp.h>
26 #include <QtCore/qstring.h>
27 #include <QtCore/qvariant.h>
28 #include <QtGui/qapplication.h>
29 #include <QtGui/qbitmap.h>
30 #include <QtGui/qcolor.h>
31 #include <QtGui/qcursor.h>
32 #include <QtGui/qfont.h>
33 #include <QtGui/qicon.h>
34 #include <QtGui/qitemselectionmodel.h>
35 #include <QtGui/qpalette.h>
36 #include <QtGui/qpen.h>
37 #include <QtGui/qpixmap.h>
38 #include <QtGui/qpolygon.h>
39 #include <QtGui/qtextformat.h>
40 #include <QtGui/qwidget.h>
43 #include <QtDBus/qdbusargument.h>
46 #include <smoke/smoke.h>
47 #include <smoke/qt_smoke.h>
50 #include "marshall_types.h"
53 extern bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
54 extern bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
56 extern TypeHandler Qt_handlers
[];
57 extern const char * resolve_classname_qt(smokeruby_object
* o
);
62 qdebug(VALUE klass
, VALUE msg
)
64 qDebug("%s", StringValuePtr(msg
));
69 qfatal(VALUE klass
, VALUE msg
)
71 qFatal("%s", StringValuePtr(msg
));
76 qwarning(VALUE klass
, VALUE msg
)
78 qWarning("%s", StringValuePtr(msg
));
82 //---------- Ruby methods (for all functions except fully qualified statics & enums) ---------
85 // Takes a variable name and a QProperty with QVariant value, and returns a '
86 // variable=value' pair with the value in ruby inspect style
88 inspectProperty(QMetaProperty property
, const char * name
, QVariant
& value
)
90 if (property
.isEnumType()) {
91 QMetaEnum e
= property
.enumerator();
92 return QString(" %1=%2::%3").arg(name
).arg(e
.scope()).arg(e
.valueToKey(value
.toInt()));
95 switch (value
.type()) {
96 case QVariant::String
:
98 if (value
.toString().isNull()) {
99 return QString(" %1=nil").arg(name
);
101 return QString(" %1=%2").arg(name
).arg(value
.toString());
108 QRegExp
name_re("^(is|has)(.)(.*)");
110 if (name_re
.indexIn(name
) != -1) {
111 rubyName
= name_re
.cap(2).toLower() + name_re
.cap(3) + "?";
116 return QString(" %1=%2").arg(rubyName
).arg(value
.toString());
119 case QVariant::Color
:
121 QColor c
= value
.value
<QColor
>();
122 return QString(" %1=#<Qt::Color:0x0 %2>").arg(name
).arg(c
.name());
125 case QVariant::Cursor
:
127 QCursor c
= value
.value
<QCursor
>();
128 return QString(" %1=#<Qt::Cursor:0x0 shape=%2>").arg(name
).arg(c
.shape());
131 case QVariant::Double
:
133 return QString(" %1=%2").arg(name
).arg(value
.toDouble());
138 QFont f
= value
.value
<QFont
>();
139 return QString( " %1=#<Qt::Font:0x0 family=%2, pointSize=%3, weight=%4, italic=%5, bold=%6, underline=%7, strikeOut=%8>")
144 .arg(f
.italic() ? "true" : "false")
145 .arg(f
.bold() ? "true" : "false")
146 .arg(f
.underline() ? "true" : "false")
147 .arg(f
.strikeOut() ? "true" : "false");
152 QLine l
= value
.toLine();
153 return QString(" %1=#<Qt::Line:0x0 x1=%2, y1=%3, x2=%4, y2=%5>")
161 case QVariant::LineF
:
163 QLineF l
= value
.toLineF();
164 return QString(" %1=#<Qt::LineF:0x0 x1=%2, y1=%3, x2=%4, y2=%5>")
172 case QVariant::Point
:
174 QPoint p
= value
.toPoint();
175 return QString(" %1=#<Qt::Point:0x0 x=%2, y=%3>").arg(name
).arg(p
.x()).arg(p
.y());
178 case QVariant::PointF
:
180 QPointF p
= value
.toPointF();
181 return QString(" %1=#<Qt::PointF:0x0 x=%2, y=%3>").arg(name
).arg(p
.x()).arg(p
.y());
186 QRect r
= value
.toRect();
187 return QString(" %1=#<Qt::Rect:0x0 left=%2, right=%3, top=%4, bottom=%5>")
189 .arg(r
.left()).arg(r
.right()).arg(r
.top()).arg(r
.bottom());
192 case QVariant::RectF
:
194 QRectF r
= value
.toRectF();
195 return QString(" %1=#<Qt::RectF:0x0 left=%2, right=%3, top=%4, bottom=%5>")
197 .arg(r
.left()).arg(r
.right()).arg(r
.top()).arg(r
.bottom());
202 QSize s
= value
.toSize();
203 return QString(" %1=#<Qt::Size:0x0 width=%2, height=%3>")
205 .arg(s
.width()).arg(s
.height());
208 case QVariant::SizeF
:
210 QSizeF s
= value
.toSizeF();
211 return QString(" %1=#<Qt::SizeF:0x0 width=%2, height=%3>")
213 .arg(s
.width()).arg(s
.height());
216 case QVariant::SizePolicy
:
218 QSizePolicy s
= value
.value
<QSizePolicy
>();
219 return QString(" %1=#<Qt::SizePolicy:0x0 horizontalPolicy=%2, verticalPolicy=%3>")
221 .arg(s
.horizontalPolicy())
222 .arg(s
.verticalPolicy());
225 case QVariant::Brush
:
226 // case QVariant::ColorGroup:
227 case QVariant::Image
:
228 case QVariant::Palette
:
229 case QVariant::Pixmap
:
230 case QVariant::Region
:
232 return QString(" %1=#<Qt::%2:0x0>").arg(name
).arg(value
.typeName() + 1);
236 return QString(" %1=%2").arg(name
)
237 .arg((value
.isNull() || value
.toString().isNull()) ? "nil" : value
.toString() );
241 // Retrieves the properties for a QObject and returns them as 'name=value' pairs
242 // in a ruby inspect string. For example:
244 // #<Qt::HBoxLayout:0x30139030 name=unnamed, margin=0, spacing=0, resizeMode=3>
247 inspect_qobject(VALUE self
)
249 if (TYPE(self
) != T_DATA
) {
253 // Start with #<Qt::HBoxLayout:0x30139030> from the original inspect() call
254 // Drop the closing '>'
255 VALUE inspect_str
= rb_call_super(0, 0);
256 rb_str_resize(inspect_str
, RSTRING_LEN(inspect_str
) - 1);
258 smokeruby_object
* o
= 0;
259 Data_Get_Struct(self
, smokeruby_object
, o
);
260 QObject
* qobject
= (QObject
*) o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
263 value_list
.append(QString(" objectName=\"%1\"").arg(qobject
->objectName()));
265 if (qobject
->isWidgetType()) {
266 QWidget
* w
= (QWidget
*) qobject
;
267 value_list
.append(QString(", x=%1, y=%2, width=%3, height=%4")
274 value_list
.append(">");
275 rb_str_cat2(inspect_str
, value_list
.toLatin1());
280 // Retrieves the properties for a QObject and pretty_prints them as 'name=value' pairs
283 // #<Qt::HBoxLayout:0x30139030
290 pretty_print_qobject(VALUE self
, VALUE pp
)
292 if (TYPE(self
) != T_DATA
) {
296 // Start with #<Qt::HBoxLayout:0x30139030>
297 // Drop the closing '>'
298 VALUE inspect_str
= rb_funcall(self
, rb_intern("to_s"), 0, 0);
299 rb_str_resize(inspect_str
, RSTRING_LEN(inspect_str
) - 1);
300 rb_funcall(pp
, rb_intern("text"), 1, inspect_str
);
301 rb_funcall(pp
, rb_intern("breakable"), 0);
303 smokeruby_object
* o
= 0;
304 Data_Get_Struct(self
, smokeruby_object
, o
);
305 QObject
* qobject
= (QObject
*) o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
309 if (qobject
->parent() != 0) {
310 QString parentInspectString
;
311 VALUE obj
= getPointerObject(qobject
->parent());
313 VALUE parent_inspect_str
= rb_funcall(obj
, rb_intern("to_s"), 0, 0);
314 rb_str_resize(parent_inspect_str
, RSTRING_LEN(parent_inspect_str
) - 1);
315 parentInspectString
= StringValuePtr(parent_inspect_str
);
317 parentInspectString
.sprintf("#<%s:0x0", qobject
->parent()->metaObject()->className());
320 if (qobject
->parent()->isWidgetType()) {
321 QWidget
* w
= (QWidget
*) qobject
->parent();
322 value_list
= QString(" parent=%1 objectName=\"%2\", x=%3, y=%4, width=%5, height=%6>,\n")
323 .arg(parentInspectString
)
324 .arg(w
->objectName())
330 value_list
= QString(" parent=%1 objectName=\"%2\">,\n")
331 .arg(parentInspectString
)
332 .arg(qobject
->parent()->objectName());
335 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(value_list
.toLatin1()));
338 if (qobject
->children().count() != 0) {
339 value_list
= QString(" children=Array (%1 element(s)),\n")
340 .arg(qobject
->children().count());
341 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(value_list
.toLatin1()));
344 value_list
= QString(" metaObject=#<Qt::MetaObject:0x0");
345 value_list
.append(QString(" className=%1").arg(qobject
->metaObject()->className()));
347 if (qobject
->metaObject()->superClass() != 0) {
348 value_list
.append( QString(", superClass=#<Qt::MetaObject:0x0 className=%1>")
349 .arg(qobject
->metaObject()->superClass()->className()) );
352 value_list
.append(">,\n");
353 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(value_list
.toLatin1()));
355 QMetaProperty property
= qobject
->metaObject()->property(0);
356 QVariant value
= property
.read(qobject
);
357 value_list
= " " + inspectProperty(property
, property
.name(), value
);
358 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(value_list
.toLatin1()));
360 for (int index
= 1; index
< qobject
->metaObject()->propertyCount(); index
++) {
361 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(",\n"));
363 property
= qobject
->metaObject()->property(index
);
364 value
= property
.read(qobject
);
365 value_list
= " " + inspectProperty(property
, property
.name(), value
);
366 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(value_list
.toLatin1()));
369 rb_funcall(pp
, rb_intern("text"), 1, rb_str_new2(">"));
375 q_register_resource_data(VALUE
/*self*/, VALUE version
, VALUE tree_value
, VALUE name_value
, VALUE data_value
)
377 const unsigned char * tree
= (const unsigned char *) malloc(RSTRING_LEN(tree_value
));
378 memcpy((void *) tree
, (const void *) RSTRING_PTR(tree_value
), RSTRING_LEN(tree_value
));
380 const unsigned char * name
= (const unsigned char *) malloc(RSTRING_LEN(name_value
));
381 memcpy((void *) name
, (const void *) RSTRING_PTR(name_value
), RSTRING_LEN(name_value
));
383 const unsigned char * data
= (const unsigned char *) malloc(RSTRING_LEN(data_value
));
384 memcpy((void *) data
, (const void *) RSTRING_PTR(data_value
), RSTRING_LEN(data_value
));
386 return qRegisterResourceData(NUM2INT(version
), tree
, name
, data
) ? Qtrue
: Qfalse
;
390 q_unregister_resource_data(VALUE
/*self*/, VALUE version
, VALUE tree_value
, VALUE name_value
, VALUE data_value
)
392 const unsigned char * tree
= (const unsigned char *) malloc(RSTRING_LEN(tree_value
));
393 memcpy((void *) tree
, (const void *) RSTRING_PTR(tree_value
), RSTRING_LEN(tree_value
));
395 const unsigned char * name
= (const unsigned char *) malloc(RSTRING_LEN(name_value
));
396 memcpy((void *) name
, (const void *) RSTRING_PTR(name_value
), RSTRING_LEN(name_value
));
398 const unsigned char * data
= (const unsigned char *) malloc(RSTRING_LEN(data_value
));
399 memcpy((void *) data
, (const void *) RSTRING_PTR(data_value
), RSTRING_LEN(data_value
));
401 return qUnregisterResourceData(NUM2INT(version
), tree
, name
, data
) ? Qtrue
: Qfalse
;
405 qabstract_item_model_rowcount(int argc
, VALUE
* argv
, VALUE self
)
407 smokeruby_object
*o
= value_obj_info(self
);
408 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
410 return INT2NUM(model
->rowCount());
414 smokeruby_object
* mi
= value_obj_info(argv
[0]);
415 QModelIndex
* modelIndex
= (QModelIndex
*) mi
->ptr
;
416 return INT2NUM(model
->rowCount(*modelIndex
));
419 rb_raise(rb_eArgError
, "Invalid argument list");
423 qabstract_item_model_columncount(int argc
, VALUE
* argv
, VALUE self
)
425 smokeruby_object
*o
= value_obj_info(self
);
426 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
428 return INT2NUM(model
->columnCount());
432 smokeruby_object
* mi
= value_obj_info(argv
[0]);
433 QModelIndex
* modelIndex
= (QModelIndex
*) mi
->ptr
;
434 return INT2NUM(model
->columnCount(*modelIndex
));
437 rb_raise(rb_eArgError
, "Invalid argument list");
441 qabstract_item_model_data(int argc
, VALUE
* argv
, VALUE self
)
443 smokeruby_object
* o
= value_obj_info(self
);
444 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
445 smokeruby_object
* mi
= value_obj_info(argv
[0]);
446 QModelIndex
* modelIndex
= (QModelIndex
*) mi
->ptr
;
449 value
= model
->data(*modelIndex
);
450 } else if (argc
== 2) {
451 value
= model
->data(*modelIndex
, NUM2INT(rb_funcall(argv
[1], rb_intern("to_i"), 0)));
453 rb_raise(rb_eArgError
, "Invalid argument list");
457 smokeruby_object
* result
= alloc_smokeruby_object( true,
459 o
->smoke
->findClass("QVariant").index
,
460 new QVariant(value
) );
461 return set_obj_info("Qt::Variant", result
);
465 qabstract_item_model_setdata(int argc
, VALUE
* argv
, VALUE self
)
467 smokeruby_object
*o
= value_obj_info(self
);
468 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
469 smokeruby_object
* mi
= value_obj_info(argv
[0]);
470 QModelIndex
* modelIndex
= (QModelIndex
*) mi
->ptr
;
471 smokeruby_object
* v
= value_obj_info(argv
[1]);
472 QVariant
* variant
= (QVariant
*) v
->ptr
;
475 return (model
->setData(*modelIndex
, *variant
) ? Qtrue
: Qfalse
);
479 return (model
->setData( *modelIndex
,
481 NUM2INT(rb_funcall(argv
[2], rb_intern("to_i"), 0)) ) ? Qtrue
: Qfalse
);
484 rb_raise(rb_eArgError
, "Invalid argument list");
488 qabstract_item_model_flags(VALUE self
, VALUE model_index
)
490 smokeruby_object
*o
= value_obj_info(self
);
491 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
492 smokeruby_object
* mi
= value_obj_info(model_index
);
493 const QModelIndex
* modelIndex
= (const QModelIndex
*) mi
->ptr
;
494 return INT2NUM((int) model
->flags(*modelIndex
));
498 qabstract_item_model_insertrows(int argc
, VALUE
* argv
, VALUE self
)
500 smokeruby_object
*o
= value_obj_info(self
);
501 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
504 return (model
->insertRows(NUM2INT(argv
[0]), NUM2INT(argv
[1])) ? Qtrue
: Qfalse
);
508 smokeruby_object
* mi
= value_obj_info(argv
[2]);
509 const QModelIndex
* modelIndex
= (const QModelIndex
*) mi
->ptr
;
510 return (model
->insertRows(NUM2INT(argv
[0]), NUM2INT(argv
[1]), *modelIndex
) ? Qtrue
: Qfalse
);
513 rb_raise(rb_eArgError
, "Invalid argument list");
517 qabstract_item_model_insertcolumns(int argc
, VALUE
* argv
, VALUE self
)
519 smokeruby_object
*o
= value_obj_info(self
);
520 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
523 return (model
->insertColumns(NUM2INT(argv
[0]), NUM2INT(argv
[1])) ? Qtrue
: Qfalse
);
527 smokeruby_object
* mi
= value_obj_info(argv
[2]);
528 const QModelIndex
* modelIndex
= (const QModelIndex
*) mi
->ptr
;
529 return (model
->insertColumns(NUM2INT(argv
[0]), NUM2INT(argv
[1]), *modelIndex
) ? Qtrue
: Qfalse
);
532 rb_raise(rb_eArgError
, "Invalid argument list");
536 qabstract_item_model_removerows(int argc
, VALUE
* argv
, VALUE self
)
538 smokeruby_object
*o
= value_obj_info(self
);
539 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
542 return (model
->removeRows(NUM2INT(argv
[0]), NUM2INT(argv
[1])) ? Qtrue
: Qfalse
);
546 smokeruby_object
* mi
= value_obj_info(argv
[2]);
547 const QModelIndex
* modelIndex
= (const QModelIndex
*) mi
->ptr
;
548 return (model
->removeRows(NUM2INT(argv
[0]), NUM2INT(argv
[1]), *modelIndex
) ? Qtrue
: Qfalse
);
551 rb_raise(rb_eArgError
, "Invalid argument list");
555 qabstract_item_model_removecolumns(int argc
, VALUE
* argv
, VALUE self
)
557 smokeruby_object
*o
= value_obj_info(self
);
558 QAbstractItemModel
* model
= (QAbstractItemModel
*) o
->ptr
;
561 return (model
->removeColumns(NUM2INT(argv
[0]), NUM2INT(argv
[1])) ? Qtrue
: Qfalse
);
565 smokeruby_object
* mi
= value_obj_info(argv
[2]);
566 const QModelIndex
* modelIndex
= (const QModelIndex
*) mi
->ptr
;
567 return (model
->removeRows(NUM2INT(argv
[0]), NUM2INT(argv
[1]), *modelIndex
) ? Qtrue
: Qfalse
);
570 rb_raise(rb_eArgError
, "Invalid argument list");
573 // There is a QByteArray operator method in the Smoke lib that takes a QString
574 // arg and returns a QString. This is normally the desired behaviour, so
575 // special case a '+' method here.
577 qbytearray_append(VALUE self
, VALUE str
)
579 smokeruby_object
*o
= value_obj_info(self
);
580 QByteArray
* bytes
= (QByteArray
*) o
->ptr
;
581 (*bytes
) += (const char *) StringValuePtr(str
);
586 qbytearray_data(VALUE self
)
588 smokeruby_object
*o
= value_obj_info(self
);
589 QByteArray
* bytes
= (QByteArray
*) o
->ptr
;
590 return rb_str_new(bytes
->data(), bytes
->size());
594 qimage_bits(VALUE self
)
596 smokeruby_object
*o
= value_obj_info(self
);
597 QImage
* image
= static_cast<QImage
*>(o
->ptr
);
598 const uchar
* bytes
= image
->bits();
599 return rb_str_new((const char *) bytes
, image
->numBytes());
603 qimage_scan_line(VALUE self
, VALUE ix
)
605 smokeruby_object
*o
= value_obj_info(self
);
606 QImage
* image
= static_cast<QImage
*>(o
->ptr
);
607 const uchar
* bytes
= image
->scanLine(NUM2INT(ix
));
608 return rb_str_new((const char *) bytes
, image
->bytesPerLine());
613 qdbusargument_endarraywrite(VALUE self
)
615 smokeruby_object
*o
= value_obj_info(self
);
616 QDBusArgument
* arg
= (QDBusArgument
*) o
->ptr
;
622 qdbusargument_endmapwrite(VALUE self
)
624 smokeruby_object
*o
= value_obj_info(self
);
625 QDBusArgument
* arg
= (QDBusArgument
*) o
->ptr
;
631 qdbusargument_endmapentrywrite(VALUE self
)
633 smokeruby_object
*o
= value_obj_info(self
);
634 QDBusArgument
* arg
= (QDBusArgument
*) o
->ptr
;
640 qdbusargument_endstructurewrite(VALUE self
)
642 smokeruby_object
*o
= value_obj_info(self
);
643 QDBusArgument
* arg
= (QDBusArgument
*) o
->ptr
;
650 // The QtRuby runtime's overloaded method resolution mechanism can't currently
651 // distinguish between Ruby Arrays containing different sort of instances.
652 // Unfortunately Qt::Painter.drawLines() and Qt::Painter.drawRects() methods can
653 // be passed a Ruby Array as an argument containing either Qt::Points or Qt::PointFs
654 // for instance. These methods need to call the correct Qt C++ methods, so special case
655 // the overload method resolution for now..
657 qpainter_drawlines(int argc
, VALUE
* argv
, VALUE self
)
659 static Smoke::Index drawlines_pointf_vector
= 0;
660 static Smoke::Index drawlines_point_vector
= 0;
661 static Smoke::Index drawlines_linef_vector
= 0;
662 static Smoke::Index drawlines_line_vector
= 0;
664 if (argc
== 1 && TYPE(argv
[0]) == T_ARRAY
&& RARRAY_LEN(argv
[0]) > 0) {
665 if (drawlines_point_vector
== 0) {
666 Smoke::ModuleIndex nameId
= qt_Smoke
->findMethodName("QPainter", "drawLines?");
667 Smoke::ModuleIndex meth
= qt_Smoke
->findMethod(qt_Smoke
->findClass("QPainter"), nameId
);
668 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
669 i
= -i
; // turn into ambiguousMethodList index
670 while (meth
.smoke
->ambiguousMethodList
[i
] != 0) {
671 const char * argType
= meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
]].name
;
673 if (qstrcmp(argType
, "const QVector<QPointF>&" ) == 0) {
674 drawlines_pointf_vector
= meth
.smoke
->ambiguousMethodList
[i
];
675 } else if (qstrcmp(argType
, "const QVector<QPoint>&" ) == 0) {
676 drawlines_point_vector
= meth
.smoke
->ambiguousMethodList
[i
];
677 } else if (qstrcmp(argType
, "const QVector<QLineF>&" ) == 0) {
678 drawlines_linef_vector
= meth
.smoke
->ambiguousMethodList
[i
];
679 } else if (qstrcmp(argType
, "const QVector<QLine>&" ) == 0) {
680 drawlines_line_vector
= meth
.smoke
->ambiguousMethodList
[i
];
687 smokeruby_object
* o
= value_obj_info(rb_ary_entry(argv
[0], 0));
689 if (qstrcmp(o
->smoke
->classes
[o
->classId
].className
, "QPointF") == 0) {
690 _current_method
.smoke
= qt_Smoke
;
691 _current_method
.index
= drawlines_pointf_vector
;
692 } else if (qstrcmp(o
->smoke
->classes
[o
->classId
].className
, "QPoint") == 0) {
693 _current_method
.smoke
= qt_Smoke
;
694 _current_method
.index
= drawlines_point_vector
;
695 } else if (qstrcmp(o
->smoke
->classes
[o
->classId
].className
, "QLineF") == 0) {
696 _current_method
.smoke
= qt_Smoke
;
697 _current_method
.index
= drawlines_linef_vector
;
698 } else if (qstrcmp(o
->smoke
->classes
[o
->classId
].className
, "QLine") == 0) {
699 _current_method
.smoke
= qt_Smoke
;
700 _current_method
.index
= drawlines_line_vector
;
702 return rb_call_super(argc
, argv
);
705 QtRuby::MethodCall
c(qt_Smoke
, _current_method
.index
, self
, argv
, argc
-1);
710 return rb_call_super(argc
, argv
);
714 qpainter_drawrects(int argc
, VALUE
* argv
, VALUE self
)
716 static Smoke::Index drawlines_rectf_vector
= 0;
717 static Smoke::Index drawlines_rect_vector
= 0;
719 if (argc
== 1 && TYPE(argv
[0]) == T_ARRAY
&& RARRAY_LEN(argv
[0]) > 0) {
720 if (drawlines_rectf_vector
== 0) {
721 Smoke::ModuleIndex nameId
= qt_Smoke
->findMethodName("QPainter", "drawRects?");
722 Smoke::ModuleIndex meth
= qt_Smoke
->findMethod(qt_Smoke
->findClass("QPainter"), nameId
);
723 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
724 i
= -i
; // turn into ambiguousMethodList index
725 while (meth
.smoke
->ambiguousMethodList
[i
] != 0) {
726 const char * argType
= meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
]].name
;
728 if (qstrcmp(argType
, "const QVector<QRectF>&" ) == 0) {
729 drawlines_rectf_vector
= meth
.smoke
->ambiguousMethodList
[i
];
730 } else if (qstrcmp(argType
, "const QVector<QRect>&" ) == 0) {
731 drawlines_rect_vector
= meth
.smoke
->ambiguousMethodList
[i
];
738 smokeruby_object
* o
= value_obj_info(rb_ary_entry(argv
[0], 0));
740 if (qstrcmp(o
->smoke
->classes
[o
->classId
].className
, "QRectF") == 0) {
741 _current_method
.smoke
= qt_Smoke
;
742 _current_method
.index
= drawlines_rectf_vector
;
743 } else if (qstrcmp(o
->smoke
->classes
[o
->classId
].className
, "QRect") == 0) {
744 _current_method
.smoke
= qt_Smoke
;
745 _current_method
.index
= drawlines_rect_vector
;
747 return rb_call_super(argc
, argv
);
750 QtRuby::MethodCall
c(qt_Smoke
, _current_method
.index
, self
, argv
, argc
-1);
755 return rb_call_super(argc
, argv
);
759 qabstractitemmodel_createindex(int argc
, VALUE
* argv
, VALUE self
)
761 if (argc
== 2 || argc
== 3) {
762 smokeruby_object
* o
= value_obj_info(self
);
763 Smoke::ModuleIndex nameId
= o
->smoke
->idMethodName("createIndex$$$");
764 Smoke::ModuleIndex meth
= o
->smoke
->findMethod(qt_Smoke
->findClass("QAbstractItemModel"), nameId
);
765 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
766 i
= -i
; // turn into ambiguousMethodList index
767 while (o
->smoke
->ambiguousMethodList
[i
] != 0) {
768 if ( qstrcmp( o
->smoke
->types
[o
->smoke
->argumentList
[o
->smoke
->methods
[o
->smoke
->ambiguousMethodList
[i
]].args
+ 2]].name
,
771 Smoke::Method
&m
= o
->smoke
->methods
[o
->smoke
->ambiguousMethodList
[i
]];
772 Smoke::ClassFn fn
= o
->smoke
->classes
[m
.classId
].classFn
;
773 Smoke::StackItem stack
[4];
774 stack
[1].s_int
= NUM2INT(argv
[0]);
775 stack
[2].s_int
= NUM2INT(argv
[1]);
777 stack
[3].s_voidp
= (void*) Qnil
;
779 stack
[3].s_voidp
= (void*) argv
[2];
781 (*fn
)(m
.method
, o
->ptr
, stack
);
782 smokeruby_object
* result
= alloc_smokeruby_object( true,
784 o
->smoke
->idClass("QModelIndex").index
,
787 return set_obj_info("Qt::ModelIndex", result
);
794 return rb_call_super(argc
, argv
);
798 qmodelindex_internalpointer(VALUE self
)
800 smokeruby_object
*o
= value_obj_info(self
);
801 QModelIndex
* index
= (QModelIndex
*) o
->ptr
;
802 void * ptr
= index
->internalPointer();
803 return ptr
!= 0 ? (VALUE
) ptr
: Qnil
;
807 qitemselection_at(VALUE self
, VALUE i
)
809 smokeruby_object
*o
= value_obj_info(self
);
810 QItemSelection
* item
= (QItemSelection
*) o
->ptr
;
811 QItemSelectionRange range
= item
->at(NUM2INT(i
));
813 smokeruby_object
* result
= alloc_smokeruby_object( true,
815 o
->smoke
->idClass("QItemSelectionRange").index
,
816 new QItemSelectionRange(range
) );
818 return set_obj_info("Qt::ItemSelectionRange", result
);
822 qitemselection_count(VALUE self
)
824 smokeruby_object
*o
= value_obj_info(self
);
825 QItemSelection
* item
= (QItemSelection
*) o
->ptr
;
826 return INT2NUM(item
->count());
830 metaObject(VALUE self
)
832 VALUE metaObject
= rb_funcall(qt_internal_module
, rb_intern("getMetaObject"), 2, Qnil
, self
);
836 /* This shouldn't be needed, but kalyptus doesn't generate a staticMetaObject
837 method for QObject::staticMetaObject, although it does for all the other
838 classes, and it isn't obvious what the problem with it is.
839 So add this as a hack to work round the bug.
842 qobject_staticmetaobject(VALUE
/*klass*/)
844 QMetaObject
* meta
= new QMetaObject(QObject::staticMetaObject
);
846 smokeruby_object
* m
= alloc_smokeruby_object( true,
848 qt_Smoke
->idClass("QMetaObject").index
,
851 VALUE obj
= set_obj_info("Qt::MetaObject", m
);
856 cast_object_to(VALUE
/*self*/, VALUE object
, VALUE new_klass
)
858 smokeruby_object
*o
= value_obj_info(object
);
860 VALUE new_klassname
= rb_funcall(new_klass
, rb_intern("name"), 0);
862 Smoke::ModuleIndex
* cast_to_id
= classcache
.value(StringValuePtr(new_klassname
));
863 if (cast_to_id
== 0) {
864 rb_raise(rb_eArgError
, "unable to find class \"%s\" to cast to\n", StringValuePtr(new_klassname
));
867 smokeruby_object
* o_cast
= alloc_smokeruby_object( o
->allocated
,
869 (int) cast_to_id
->index
,
870 o
->smoke
->cast(o
->ptr
, o
->classId
, (int) cast_to_id
->index
) );
872 VALUE obj
= Data_Wrap_Struct(new_klass
, smokeruby_mark
, smokeruby_free
, (void *) o_cast
);
873 mapPointer(obj
, o_cast
, o_cast
->classId
, 0);
878 qobject_qt_metacast(VALUE self
, VALUE klass
)
880 smokeruby_object
*o
= value_obj_info(self
);
881 if (o
== 0 || o
->ptr
== 0) {
885 const char * classname
= rb_class2name(klass
);
886 Smoke::ModuleIndex
* mi
= classcache
.value(classname
);
891 QObject
* qobj
= (QObject
*) o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
896 void* ret
= qobj
->qt_metacast(mi
->smoke
->classes
[mi
->index
].className
);
902 smokeruby_object
* o_cast
= alloc_smokeruby_object( o
->allocated
,
907 VALUE obj
= Data_Wrap_Struct(klass
, smokeruby_mark
, smokeruby_free
, (void *) o_cast
);
908 mapPointer(obj
, o_cast
, o_cast
->classId
, 0);
913 qsignalmapper_mapping(int argc
, VALUE
* argv
, VALUE self
)
915 if (argc
== 1 && TYPE(argv
[0]) == T_DATA
) {
916 smokeruby_object
*o
= value_obj_info(self
);
917 smokeruby_object
*a
= value_obj_info(argv
[0]);
919 Smoke::ModuleIndex nameId
= qt_Smoke
->NullModuleIndex
;
920 nameId
= o
->smoke
->idMethodName("mapping#");
921 Smoke::ModuleIndex ci
= { o
->smoke
, o
->classId
};
922 Smoke::ModuleIndex meth
= o
->smoke
->findMethod(ci
, nameId
);
923 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
924 i
= -i
; // turn into ambiguousMethodList index
925 while (meth
.smoke
->ambiguousMethodList
[i
] != 0) {
926 if ( ( qstrcmp( meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
]].name
,
928 && a
->smoke
->isDerivedFromByName(a
->smoke
->classes
[a
->classId
].className
, "QObject")
929 && !a
->smoke
->isDerivedFromByName(a
->smoke
->classes
[a
->classId
].className
, "QWidget") )
930 || ( qstrcmp( meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
]].name
,
932 && a
->smoke
->isDerivedFromByName(a
->smoke
->classes
[a
->classId
].className
, "QWidget") ) )
934 _current_method
.smoke
= meth
.smoke
;
935 _current_method
.index
= meth
.smoke
->ambiguousMethodList
[i
];
936 QtRuby::MethodCall
c(meth
.smoke
, _current_method
.index
, self
, argv
, 1);
945 return rb_call_super(argc
, argv
);
949 qsignalmapper_set_mapping(int argc
, VALUE
* argv
, VALUE self
)
951 if (argc
== 2 && TYPE(argv
[0]) == T_DATA
&& TYPE(argv
[1]) == T_DATA
) {
952 smokeruby_object
*o
= value_obj_info(self
);
953 smokeruby_object
*a
= value_obj_info(argv
[1]);
955 Smoke::ModuleIndex nameId
= qt_Smoke
->NullModuleIndex
;
956 nameId
= o
->smoke
->idMethodName("setMapping##");
957 Smoke::ModuleIndex ci
= { o
->smoke
, o
->classId
};
958 Smoke::ModuleIndex meth
= o
->smoke
->findMethod(ci
, nameId
);
959 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
960 i
= -i
; // turn into ambiguousMethodList index
961 while (meth
.smoke
->ambiguousMethodList
[i
] != 0) {
962 if ( ( qstrcmp( meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
+ 1]].name
,
964 && a
->smoke
->isDerivedFromByName(a
->smoke
->classes
[a
->classId
].className
, "QObject")
965 && !a
->smoke
->isDerivedFromByName(a
->smoke
->classes
[a
->classId
].className
, "QWidget") )
966 || ( qstrcmp( meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
+ 1]].name
,
968 && a
->smoke
->isDerivedFromByName(a
->smoke
->classes
[a
->classId
].className
, "QWidget") ) )
970 _current_method
.smoke
= meth
.smoke
;
971 _current_method
.index
= meth
.smoke
->ambiguousMethodList
[i
];
972 QtRuby::MethodCall
c(meth
.smoke
, _current_method
.index
, self
, argv
, 2);
981 return rb_call_super(argc
, argv
);
985 qvariant_value(VALUE
/*self*/, VALUE variant_value_klass
, VALUE variant_value
)
987 void * value_ptr
= 0;
989 smokeruby_object
* vo
= 0;
991 smokeruby_object
*o
= value_obj_info(variant_value
);
992 if (o
== 0 || o
->ptr
== 0) {
996 QVariant
* variant
= (QVariant
*) o
->ptr
;
998 // If the QVariant contains a user type, don't bother to look at the Ruby class argument
999 if (variant
->type() >= QVariant::UserType
) {
1001 if (qstrcmp(variant
->typeName(), "QDBusObjectPath") == 0) {
1002 QString s
= qVariantValue
<QDBusObjectPath
>(*variant
).path();
1003 return rb_str_new2(s
.toLatin1());
1004 } else if (qstrcmp(variant
->typeName(), "QDBusSignature") == 0) {
1005 QString s
= qVariantValue
<QDBusSignature
>(*variant
).signature();
1006 return rb_str_new2(s
.toLatin1());
1010 value_ptr
= QMetaType::construct(QMetaType::type(variant
->typeName()), (void *) variant
->constData());
1011 Smoke::ModuleIndex mi
= o
->smoke
->findClass(variant
->typeName());
1012 vo
= alloc_smokeruby_object(true, mi
.smoke
, mi
.index
, value_ptr
);
1013 return set_obj_info(qtruby_modules
[mi
.smoke
].binding
->className(mi
.index
), vo
);
1016 const char * classname
= rb_class2name(variant_value_klass
);
1017 Smoke::ModuleIndex
* value_class_id
= classcache
.value(classname
);
1018 if (value_class_id
== 0) {
1022 if (qstrcmp(classname
, "Qt::Pixmap") == 0) {
1023 QPixmap v
= qVariantValue
<QPixmap
>(*variant
);
1024 value_ptr
= (void *) new QPixmap(v
);
1025 } else if (qstrcmp(classname
, "Qt::Font") == 0) {
1026 QFont v
= qVariantValue
<QFont
>(*variant
);
1027 value_ptr
= (void *) new QFont(v
);
1028 } else if (qstrcmp(classname
, "Qt::Brush") == 0) {
1029 QBrush v
= qVariantValue
<QBrush
>(*variant
);
1030 value_ptr
= (void *) new QBrush(v
);
1031 } else if (qstrcmp(classname
, "Qt::Color") == 0) {
1032 QColor v
= qVariantValue
<QColor
>(*variant
);
1033 value_ptr
= (void *) new QColor(v
);
1034 } else if (qstrcmp(classname
, "Qt::Palette") == 0) {
1035 QPalette v
= qVariantValue
<QPalette
>(*variant
);
1036 value_ptr
= (void *) new QPalette(v
);
1037 } else if (qstrcmp(classname
, "Qt::Icon") == 0) {
1038 QIcon v
= qVariantValue
<QIcon
>(*variant
);
1039 value_ptr
= (void *) new QIcon(v
);
1040 } else if (qstrcmp(classname
, "Qt::Image") == 0) {
1041 QImage v
= qVariantValue
<QImage
>(*variant
);
1042 value_ptr
= (void *) new QImage(v
);
1043 } else if (qstrcmp(classname
, "Qt::Polygon") == 0) {
1044 QPolygon v
= qVariantValue
<QPolygon
>(*variant
);
1045 value_ptr
= (void *) new QPolygon(v
);
1046 } else if (qstrcmp(classname
, "Qt::Region") == 0) {
1047 QRegion v
= qVariantValue
<QRegion
>(*variant
);
1048 value_ptr
= (void *) new QRegion(v
);
1049 } else if (qstrcmp(classname
, "Qt::Bitmap") == 0) {
1050 QBitmap v
= qVariantValue
<QBitmap
>(*variant
);
1051 value_ptr
= (void *) new QBitmap(v
);
1052 } else if (qstrcmp(classname
, "Qt::Cursor") == 0) {
1053 QCursor v
= qVariantValue
<QCursor
>(*variant
);
1054 value_ptr
= (void *) new QCursor(v
);
1055 } else if (qstrcmp(classname
, "Qt::SizePolicy") == 0) {
1056 QSizePolicy v
= qVariantValue
<QSizePolicy
>(*variant
);
1057 value_ptr
= (void *) new QSizePolicy(v
);
1058 } else if (qstrcmp(classname
, "Qt::KeySequence") == 0) {
1059 QKeySequence v
= qVariantValue
<QKeySequence
>(*variant
);
1060 value_ptr
= (void *) new QKeySequence(v
);
1061 } else if (qstrcmp(classname
, "Qt::Pen") == 0) {
1062 QPen v
= qVariantValue
<QPen
>(*variant
);
1063 value_ptr
= (void *) new QPen(v
);
1064 } else if (qstrcmp(classname
, "Qt::TextLength") == 0) {
1065 QTextLength v
= qVariantValue
<QTextLength
>(*variant
);
1066 value_ptr
= (void *) new QTextLength(v
);
1067 } else if (qstrcmp(classname
, "Qt::TextFormat") == 0) {
1068 QTextFormat v
= qVariantValue
<QTextFormat
>(*variant
);
1069 value_ptr
= (void *) new QTextFormat(v
);
1070 } else if (qstrcmp(classname
, "Qt::Variant") == 0) {
1071 value_ptr
= (void *) new QVariant(*((QVariant
*) variant
->constData()));
1073 // Assume the value of the Qt::Variant can be obtained
1074 // with a call such as Qt::Variant.toPoint()
1075 QByteArray
toValueMethodName(classname
);
1076 if (toValueMethodName
.startsWith("Qt::")) {
1077 toValueMethodName
.remove(0, strlen("Qt::"));
1079 toValueMethodName
.prepend("to");
1080 return rb_funcall(variant_value
, rb_intern(toValueMethodName
), 1, variant_value
);
1083 vo
= alloc_smokeruby_object(true, value_class_id
->smoke
, value_class_id
->index
, value_ptr
);
1084 result
= set_obj_info(classname
, vo
);
1090 qvariant_from_value(int argc
, VALUE
* argv
, VALUE self
)
1093 Smoke::ModuleIndex nameId
= qt_Smoke
->NullModuleIndex
;
1094 if (TYPE(argv
[0]) == T_DATA
) {
1095 nameId
= qt_Smoke
->idMethodName("QVariant#");
1096 } else if (TYPE(argv
[0]) == T_ARRAY
|| TYPE(argv
[0]) == T_ARRAY
) {
1097 nameId
= qt_Smoke
->idMethodName("QVariant?");
1099 nameId
= qt_Smoke
->idMethodName("QVariant$");
1102 Smoke::ModuleIndex meth
= qt_Smoke
->findMethod(qt_Smoke
->idClass("QVariant"), nameId
);
1103 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
1104 i
= -i
; // turn into ambiguousMethodList index
1105 while (meth
.smoke
->ambiguousMethodList
[i
] != 0) {
1106 if ( qstrcmp( meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
]].name
,
1107 StringValuePtr(argv
[1]) ) == 0 )
1109 _current_method
.smoke
= meth
.smoke
;
1110 _current_method
.index
= meth
.smoke
->ambiguousMethodList
[i
];
1111 QtRuby::MethodCall
c(meth
.smoke
, _current_method
.index
, self
, argv
, 0);
1120 const char * classname
= rb_obj_classname(argv
[0]);
1121 smokeruby_object
*o
= value_obj_info(argv
[0]);
1122 if (o
== 0 || o
->ptr
== 0) {
1123 // Assume the Qt::Variant can be created with a
1124 // Qt::Variant.new(obj) call
1125 if (qstrcmp(classname
, "Qt::Enum") == 0) {
1126 return rb_funcall(qvariant_class
, rb_intern("new"), 1, rb_funcall(argv
[0], rb_intern("to_i"), 0));
1128 return rb_funcall(qvariant_class
, rb_intern("new"), 1, argv
[0]);
1134 if (qstrcmp(classname
, "Qt::Pixmap") == 0) {
1135 v
= new QVariant(qVariantFromValue(*(QPixmap
*) o
->ptr
));
1136 } else if (qstrcmp(classname
, "Qt::Font") == 0) {
1137 v
= new QVariant(qVariantFromValue(*(QFont
*) o
->ptr
));
1138 } else if (qstrcmp(classname
, "Qt::Brush") == 0) {
1139 v
= new QVariant(qVariantFromValue(*(QBrush
*) o
->ptr
));
1140 } else if (qstrcmp(classname
, "Qt::Color") == 0) {
1141 v
= new QVariant(qVariantFromValue(*(QColor
*) o
->ptr
));
1142 } else if (qstrcmp(classname
, "Qt::Palette") == 0) {
1143 v
= new QVariant(qVariantFromValue(*(QPalette
*) o
->ptr
));
1144 } else if (qstrcmp(classname
, "Qt::Icon") == 0) {
1145 v
= new QVariant(qVariantFromValue(*(QIcon
*) o
->ptr
));
1146 } else if (qstrcmp(classname
, "Qt::Image") == 0) {
1147 v
= new QVariant(qVariantFromValue(*(QImage
*) o
->ptr
));
1148 } else if (qstrcmp(classname
, "Qt::Polygon") == 0) {
1149 v
= new QVariant(qVariantFromValue(*(QPolygon
*) o
->ptr
));
1150 } else if (qstrcmp(classname
, "Qt::Region") == 0) {
1151 v
= new QVariant(qVariantFromValue(*(QRegion
*) o
->ptr
));
1152 } else if (qstrcmp(classname
, "Qt::Bitmap") == 0) {
1153 v
= new QVariant(qVariantFromValue(*(QBitmap
*) o
->ptr
));
1154 } else if (qstrcmp(classname
, "Qt::Cursor") == 0) {
1155 v
= new QVariant(qVariantFromValue(*(QCursor
*) o
->ptr
));
1156 } else if (qstrcmp(classname
, "Qt::SizePolicy") == 0) {
1157 v
= new QVariant(qVariantFromValue(*(QSizePolicy
*) o
->ptr
));
1158 } else if (qstrcmp(classname
, "Qt::KeySequence") == 0) {
1159 v
= new QVariant(qVariantFromValue(*(QKeySequence
*) o
->ptr
));
1160 } else if (qstrcmp(classname
, "Qt::Pen") == 0) {
1161 v
= new QVariant(qVariantFromValue(*(QPen
*) o
->ptr
));
1162 } else if (qstrcmp(classname
, "Qt::TextLength") == 0) {
1163 v
= new QVariant(qVariantFromValue(*(QTextLength
*) o
->ptr
));
1164 } else if (qstrcmp(classname
, "Qt::TextFormat") == 0) {
1165 v
= new QVariant(qVariantFromValue(*(QTextFormat
*) o
->ptr
));
1166 } else if (QVariant::nameToType(o
->smoke
->classes
[o
->classId
].className
) >= QVariant::UserType
) {
1167 v
= new QVariant(QMetaType::type(o
->smoke
->classes
[o
->classId
].className
), o
->ptr
);
1169 // Assume the Qt::Variant can be created with a
1170 // Qt::Variant.new(obj) call
1171 return rb_funcall(qvariant_class
, rb_intern("new"), 1, argv
[0]);
1174 smokeruby_object
* vo
= alloc_smokeruby_object(true, qt_Smoke
, qt_Smoke
->idClass("QVariant").index
, v
);
1175 VALUE result
= set_obj_info("Qt::Variant", vo
);
1181 new_qvariant(int argc
, VALUE
* argv
, VALUE self
)
1183 static Smoke::Index new_qvariant_qlist
= 0;
1184 static Smoke::Index new_qvariant_qmap
= 0;
1186 if (new_qvariant_qlist
== 0) {
1187 Smoke::ModuleIndex nameId
= qt_Smoke
->findMethodName("Qvariant", "QVariant?");
1188 Smoke::ModuleIndex meth
= qt_Smoke
->findMethod(qt_Smoke
->findClass("QVariant"), nameId
);
1189 Smoke::Index i
= meth
.smoke
->methodMaps
[meth
.index
].method
;
1190 i
= -i
; // turn into ambiguousMethodList index
1191 while (qt_Smoke
->ambiguousMethodList
[i
] != 0) {
1192 const char * argType
= meth
.smoke
->types
[meth
.smoke
->argumentList
[meth
.smoke
->methods
[meth
.smoke
->ambiguousMethodList
[i
]].args
]].name
;
1194 if (qstrcmp(argType
, "const QList<QVariant>&" ) == 0) {
1195 new_qvariant_qlist
= meth
.smoke
->ambiguousMethodList
[i
];
1196 } else if (qstrcmp(argType
, "const QMap<QString,QVariant>&" ) == 0) {
1197 new_qvariant_qmap
= meth
.smoke
->ambiguousMethodList
[i
];
1204 if (argc
== 1 && TYPE(argv
[0]) == T_HASH
) {
1205 _current_method
.smoke
= qt_Smoke
;
1206 _current_method
.index
= new_qvariant_qmap
;
1207 QtRuby::MethodCall
c(qt_Smoke
, _current_method
.index
, self
, argv
, argc
-1);
1210 } else if ( argc
== 1
1211 && TYPE(argv
[0]) == T_ARRAY
1212 && RARRAY_LEN(argv
[0]) > 0
1213 && TYPE(rb_ary_entry(argv
[0], 0)) != T_STRING
)
1215 _current_method
.smoke
= qt_Smoke
;
1216 _current_method
.index
= new_qvariant_qlist
;
1217 QtRuby::MethodCall
c(qt_Smoke
, _current_method
.index
, self
, argv
, argc
-1);
1222 return rb_call_super(argc
, argv
);
1225 static VALUE
module_method_missing(int argc
, VALUE
* argv
, VALUE klass
)
1227 return class_method_missing(argc
, argv
, klass
);
1232 class LCDRange < Qt::Widget
1234 def initialize(s, parent, name)
1239 For a case such as the above, the QWidget can't be instantiated until
1240 the initializer has been run up to the point where 'super(parent, name)'
1241 is called. Only then, can the number and type of arguments passed to the
1242 constructor be known. However, the rest of the intializer
1243 can't be run until 'self' is a proper T_DATA object with a wrapped C++
1246 The solution is to run the initialize code twice. First, only up to the
1247 'super(parent, name)' call, where the QWidget would get instantiated in
1248 initialize_qt(). And then rb_throw() jumps out of the
1249 initializer returning the wrapped object as a result.
1251 The second time round 'self' will be the wrapped instance of type T_DATA,
1252 so initialize() can be allowed to proceed to the end.
1255 initialize_qt(int argc
, VALUE
* argv
, VALUE self
)
1257 VALUE retval
= Qnil
;
1260 if (TYPE(self
) == T_DATA
) {
1261 // If a ruby block was passed then run that now
1262 if (rb_block_given_p()) {
1263 rb_funcall(qt_internal_module
, rb_intern("run_initializer_block"), 2, self
, rb_block_proc());
1269 VALUE klass
= rb_funcall(self
, rb_intern("class"), 0);
1270 VALUE constructor_name
= rb_str_new2("new");
1272 VALUE
* temp_stack
= ALLOCA_N(VALUE
, argc
+4);
1274 temp_stack
[0] = rb_str_new2("Qt");
1275 temp_stack
[1] = constructor_name
;
1276 temp_stack
[2] = klass
;
1277 temp_stack
[3] = self
;
1279 for (int count
= 0; count
< argc
; count
++) {
1280 temp_stack
[count
+4] = argv
[count
];
1284 QByteArray
* mcid
= find_cached_selector(argc
+4, temp_stack
, klass
, rb_class2name(klass
));
1286 if (_current_method
.index
== -1) {
1287 retval
= rb_funcall2(qt_internal_module
, rb_intern("do_method_missing"), argc
+4, temp_stack
);
1288 if (_current_method
.index
!= -1) {
1289 // Success. Cache result.
1290 methcache
.insert(*mcid
, new Smoke::ModuleIndex(_current_method
));
1295 if (_current_method
.index
== -1) {
1296 // Another longjmp here..
1297 rb_raise(rb_eArgError
, "unresolved constructor call %s\n", rb_class2name(klass
));
1301 // Allocate the MethodCall within a C block. Otherwise, because the continue_new_instance()
1302 // call below will longjmp out, it wouldn't give C++ an opportunity to clean up
1303 QtRuby::MethodCall
c(_current_method
.smoke
, _current_method
.index
, self
, temp_stack
+4, argc
);
1305 temp_obj
= *(c
.var());
1308 smokeruby_object
* p
= 0;
1309 Data_Get_Struct(temp_obj
, smokeruby_object
, p
);
1311 smokeruby_object
* o
= alloc_smokeruby_object( true,
1316 p
->allocated
= false;
1318 VALUE result
= Data_Wrap_Struct(klass
, smokeruby_mark
, smokeruby_free
, o
);
1319 mapObject(result
, result
);
1320 // Off with a longjmp, never to return..
1321 rb_throw("newqt", result
);
1327 new_qt(int argc
, VALUE
* argv
, VALUE klass
)
1329 VALUE
* temp_stack
= ALLOCA_N(VALUE
, argc
+ 1);
1330 temp_stack
[0] = rb_obj_alloc(klass
);
1332 for (int count
= 0; count
< argc
; count
++) {
1333 temp_stack
[count
+1] = argv
[count
];
1336 VALUE result
= rb_funcall2(qt_internal_module
, rb_intern("try_initialize"), argc
+1, temp_stack
);
1337 rb_obj_call_init(result
, argc
, argv
);
1343 // Returns $qApp.ARGV() - the original ARGV array with Qt command line options removed
1345 qapplication_argv(VALUE
/*self*/)
1347 VALUE result
= rb_ary_new();
1348 // Drop argv[0], as it isn't included in the ruby global ARGV
1349 for (int index
= 1; index
< qApp
->argc(); index
++) {
1350 rb_ary_push(result
, rb_str_new2(qApp
->argv()[index
]));
1356 //----------------- Sig/Slot ------------------
1360 qt_signal(int argc
, VALUE
* argv
, VALUE self
)
1362 smokeruby_object
*o
= value_obj_info(self
);
1363 QObject
*qobj
= (QObject
*)o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
1364 if (qobj
->signalsBlocked()) {
1368 #if RUBY_VERSION >= 0x10900
1369 QLatin1String
signalname(rb_id2name(rb_frame_callee()));
1371 QLatin1String
signalname(rb_id2name(rb_frame_last_func()));
1373 VALUE metaObject_value
= rb_funcall(qt_internal_module
, rb_intern("getMetaObject"), 2, Qnil
, self
);
1375 smokeruby_object
*ometa
= value_obj_info(metaObject_value
);
1381 const QMetaObject
* m
= (QMetaObject
*) ometa
->ptr
;
1382 for (i
= m
->methodCount() - 1; i
> -1; i
--) {
1383 if (m
->method(i
).methodType() == QMetaMethod::Signal
) {
1384 QString
name(m
->method(i
).signature());
1385 static QRegExp
* rx
= 0;
1387 rx
= new QRegExp("\\(.*");
1389 name
.replace(*rx
, "");
1391 if (name
== signalname
) {
1401 QList
<MocArgument
*> args
= get_moc_arguments(o
->smoke
, m
->method(i
).typeName(), m
->method(i
).parameterTypes());
1403 VALUE result
= Qnil
;
1404 // Okay, we have the signal info. *whew*
1405 QtRuby::EmitSignal
signal(qobj
, i
, argc
, args
, argv
, &result
);
1412 qt_metacall(int /*argc*/, VALUE
* argv
, VALUE self
)
1414 // Arguments: QMetaObject::Call _c, int id, void ** _o
1415 QMetaObject::Call _c
= (QMetaObject::Call
) NUM2INT( rb_funcall( qt_internal_module
,
1416 rb_intern("get_qinteger"),
1419 int id
= NUM2INT(argv
[1]);
1422 // Note that for a slot with no args and no return type,
1423 // it isn't an error to get a NULL value of _o here.
1424 Data_Get_Struct(argv
[2], void*, _o
);
1425 // Assume the target slot is a C++ one
1426 smokeruby_object
*o
= value_obj_info(self
);
1427 Smoke::ModuleIndex nameId
= o
->smoke
->idMethodName("qt_metacall$$?");
1428 Smoke::ModuleIndex classIdx
= { o
->smoke
, o
->classId
};
1429 Smoke::ModuleIndex meth
= nameId
.smoke
->findMethod(classIdx
, nameId
);
1430 if (meth
.index
> 0) {
1431 Smoke::Method
&m
= meth
.smoke
->methods
[meth
.smoke
->methodMaps
[meth
.index
].method
];
1432 Smoke::ClassFn fn
= meth
.smoke
->classes
[m
.classId
].classFn
;
1433 Smoke::StackItem i
[4];
1437 (*fn
)(m
.method
, o
->ptr
, i
);
1438 int ret
= i
[0].s_int
;
1440 return INT2NUM(ret
);
1443 // Should never happen..
1444 rb_raise(rb_eRuntimeError
, "Cannot find %s::qt_metacall() method\n",
1445 o
->smoke
->classes
[o
->classId
].className
);
1448 if (_c
!= QMetaObject::InvokeMetaMethod
) {
1452 QObject
* qobj
= (QObject
*) o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
1453 // get obj metaobject with a virtual call
1454 const QMetaObject
*metaobject
= qobj
->metaObject();
1456 // get method/property count
1458 if (_c
== QMetaObject::InvokeMetaMethod
) {
1459 count
= metaobject
->methodCount();
1461 count
= metaobject
->propertyCount();
1464 if (_c
== QMetaObject::InvokeMetaMethod
) {
1465 QMetaMethod method
= metaobject
->method(id
);
1467 if (method
.methodType() == QMetaMethod::Signal
) {
1468 metaobject
->activate(qobj
, id
, (void**) _o
);
1469 return INT2NUM(id
- count
);
1472 QList
<MocArgument
*> mocArgs
= get_moc_arguments(o
->smoke
, method
.typeName(), method
.parameterTypes());
1474 QString
name(method
.signature());
1475 static QRegExp
* rx
= 0;
1477 rx
= new QRegExp("\\(.*");
1479 name
.replace(*rx
, "");
1480 QtRuby::InvokeSlot
slot(self
, rb_intern(name
.toLatin1()), mocArgs
, _o
);
1484 return INT2NUM(id
- count
);
1488 qobject_connect(int argc
, VALUE
* argv
, VALUE self
)
1490 if (rb_block_given_p()) {
1492 return rb_funcall(qt_internal_module
, rb_intern("signal_connect"), 3, self
, argv
[0], rb_block_proc());
1493 } else if (argc
== 2) {
1494 return rb_funcall(qt_internal_module
, rb_intern("connect"), 4, argv
[0], argv
[1], self
, rb_block_proc());
1495 } else if (argc
== 3) {
1496 return rb_funcall(qt_internal_module
, rb_intern("connect"), 4, argv
[0], argv
[1], argv
[2], rb_block_proc());
1498 rb_raise(rb_eArgError
, "Invalid argument list");
1501 if (argc
== 3 && TYPE(argv
[1]) != T_STRING
) {
1502 return rb_funcall(qt_internal_module
, rb_intern("method_connect"), 4, self
, argv
[0], argv
[1], argv
[2]);
1504 return rb_call_super(argc
, argv
);
1510 qtimer_single_shot(int argc
, VALUE
* argv
, VALUE
/*self*/)
1512 if (rb_block_given_p()) {
1514 return rb_funcall(qt_internal_module
, rb_intern("single_shot_timer_connect"), 3, argv
[0], argv
[1], rb_block_proc());
1516 rb_raise(rb_eArgError
, "Invalid argument list");
1519 return rb_call_super(argc
, argv
);
1523 // --------------- Ruby C functions for Qt::_internal.* helpers ----------------
1527 getMethStat(VALUE
/*self*/)
1529 VALUE result_list
= rb_ary_new();
1530 rb_ary_push(result_list
, INT2NUM((int)methcache
.size()));
1531 rb_ary_push(result_list
, INT2NUM((int)methcache
.count()));
1536 getClassStat(VALUE
/*self*/)
1538 VALUE result_list
= rb_ary_new();
1539 rb_ary_push(result_list
, INT2NUM((int)classcache
.size()));
1540 rb_ary_push(result_list
, INT2NUM((int)classcache
.count()));
1545 getIsa(VALUE
/*self*/, VALUE classId
)
1547 VALUE parents_list
= rb_ary_new();
1549 int id
= NUM2INT(rb_funcall(classId
, rb_intern("index"), 0));
1550 Smoke
* smoke
= smokeList
[NUM2INT(rb_funcall(classId
, rb_intern("smoke"), 0))];
1552 Smoke::Index
*parents
=
1553 smoke
->inheritanceList
+
1554 smoke
->classes
[id
].parents
;
1557 //logger("\tparent: %s", qt_Smoke->classes[*parents].className);
1558 rb_ary_push(parents_list
, rb_str_new2(smoke
->classes
[*parents
++].className
));
1560 return parents_list
;
1563 // Return the class name of a QObject. Note that the name will be in the
1564 // form of Qt::Widget rather than QWidget. Is this a bug or a feature?
1566 class_name(VALUE self
)
1568 VALUE klass
= rb_funcall(self
, rb_intern("class"), 0);
1569 return rb_funcall(klass
, rb_intern("name"), 0);
1572 // Allow classnames in both 'Qt::Widget' and 'QWidget' formats to be
1573 // used as an argument to Qt::Object.inherits()
1575 inherits_qobject(int argc
, VALUE
* argv
, VALUE
/*self*/)
1578 return rb_call_super(argc
, argv
);
1581 Smoke::ModuleIndex
* classId
= classcache
.value(StringValuePtr(argv
[0]));
1584 return rb_call_super(argc
, argv
);
1586 VALUE super_class
= rb_str_new2(classId
->smoke
->classes
[classId
->index
].className
);
1587 return rb_call_super(argc
, &super_class
);
1591 /* Adapted from the internal function qt_qFindChildren() in qobject.cpp */
1593 rb_qFindChildren_helper(VALUE parent
, const QString
&name
, VALUE re
,
1594 const QMetaObject
&mo
, VALUE list
)
1596 if (parent
== Qnil
|| list
== Qnil
)
1598 VALUE children
= rb_funcall(parent
, rb_intern("children"), 0);
1600 for (int i
= 0; i
< RARRAY_LEN(children
); ++i
) {
1601 rv
= RARRAY_PTR(children
)[i
];
1602 smokeruby_object
*o
= value_obj_info(rv
);
1603 QObject
* obj
= (QObject
*) o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
1605 // The original code had 'if (mo.cast(obj))' as a test, but it doesn't work here
1606 if (obj
->qt_metacast(mo
.className()) != 0) {
1608 VALUE re_test
= rb_funcall(re
, rb_intern("=~"), 1, rb_funcall(rv
, rb_intern("objectName"), 0));
1609 if (re_test
!= Qnil
&& re_test
!= Qfalse
) {
1610 rb_ary_push(list
, rv
);
1613 if (name
.isNull() || obj
->objectName() == name
) {
1614 rb_ary_push(list
, rv
);
1618 rb_qFindChildren_helper(rv
, name
, re
, mo
, list
);
1623 /* Should mimic Qt4's QObject::findChildren method with this syntax:
1624 obj.findChildren(Qt::Widget, "Optional Widget Name")
1627 find_qobject_children(int argc
, VALUE
*argv
, VALUE self
)
1629 if (argc
< 1 || argc
> 2) rb_raise(rb_eArgError
, "Invalid argument list");
1630 Check_Type(argv
[0], T_CLASS
);
1635 // If the second arg isn't a String, assume it's a regular expression
1636 if (TYPE(argv
[1]) == T_STRING
) {
1637 name
= QString::fromLatin1(StringValuePtr(argv
[1]));
1643 VALUE metaObject
= rb_funcall(argv
[0], rb_intern("staticMetaObject"), 0);
1644 smokeruby_object
*o
= value_obj_info(metaObject
);
1645 QMetaObject
* mo
= (QMetaObject
*) o
->ptr
;
1646 VALUE result
= rb_ary_new();
1647 rb_qFindChildren_helper(self
, name
, re
, *mo
, result
);
1651 /* Adapted from the internal function qt_qFindChild() in qobject.cpp */
1653 rb_qFindChild_helper(VALUE parent
, const QString
&name
, const QMetaObject
&mo
)
1657 VALUE children
= rb_funcall(parent
, rb_intern("children"), 0);
1660 for (i
= 0; i
< RARRAY_LEN(children
); ++i
) {
1661 rv
= RARRAY_PTR(children
)[i
];
1662 smokeruby_object
*o
= value_obj_info(rv
);
1663 QObject
* obj
= (QObject
*) o
->smoke
->cast(o
->ptr
, o
->classId
, o
->smoke
->idClass("QObject").index
);
1664 if (obj
->qt_metacast(mo
.className()) != 0 && (name
.isNull() || obj
->objectName() == name
))
1667 for (i
= 0; i
< RARRAY_LEN(children
); ++i
) {
1668 rv
= rb_qFindChild_helper(RARRAY_PTR(children
)[i
], name
, mo
);
1676 find_qobject_child(int argc
, VALUE
*argv
, VALUE self
)
1678 if (argc
< 1 || argc
> 2) rb_raise(rb_eArgError
, "Invalid argument list");
1679 Check_Type(argv
[0], T_CLASS
);
1683 name
= QString::fromLatin1(StringValuePtr(argv
[1]));
1686 VALUE metaObject
= rb_funcall(argv
[0], rb_intern("staticMetaObject"), 0);
1687 smokeruby_object
*o
= value_obj_info(metaObject
);
1688 QMetaObject
* mo
= (QMetaObject
*) o
->ptr
;
1689 return rb_qFindChild_helper(self
, name
, *mo
);
1693 setDebug(VALUE self
, VALUE on_value
)
1695 int on
= NUM2INT(on_value
);
1701 debugging(VALUE
/*self*/)
1703 return INT2NUM(do_debug
);
1707 get_arg_type_name(VALUE
/*self*/, VALUE method_value
, VALUE idx_value
)
1709 int method
= NUM2INT(rb_funcall(method_value
, rb_intern("index"), 0));
1710 int smokeIndex
= NUM2INT(rb_funcall(method_value
, rb_intern("smoke"), 0));
1711 Smoke
* smoke
= smokeList
[smokeIndex
];
1712 int idx
= NUM2INT(idx_value
);
1713 Smoke::Method
&m
= smoke
->methods
[method
];
1714 Smoke::Index
*args
= smoke
->argumentList
+ m
.args
;
1715 return rb_str_new2((char*)smoke
->types
[args
[idx
]].name
);
1719 classIsa(VALUE
/*self*/, VALUE className_value
, VALUE base_value
)
1721 char *className
= StringValuePtr(className_value
);
1722 char *base
= StringValuePtr(base_value
);
1723 return qt_Smoke
->isDerivedFromByName(className
, base
) ? Qtrue
: Qfalse
;
1727 isEnum(VALUE
/*self*/, VALUE enumName_value
)
1729 char *enumName
= StringValuePtr(enumName_value
);
1730 Smoke::Index typeId
= 0;
1732 for (int i
= 0; i
< smokeList
.count(); i
++) {
1733 typeId
= smokeList
[i
]->idType(enumName
);
1740 && ( (s
->types
[typeId
].flags
& Smoke::tf_elem
) == Smoke::t_enum
1741 || (s
->types
[typeId
].flags
& Smoke::tf_elem
) == Smoke::t_ulong
1742 || (s
->types
[typeId
].flags
& Smoke::tf_elem
) == Smoke::t_long
1743 || (s
->types
[typeId
].flags
& Smoke::tf_elem
) == Smoke::t_uint
1744 || (s
->types
[typeId
].flags
& Smoke::tf_elem
) == Smoke::t_int
) ? Qtrue
: Qfalse
;
1748 insert_pclassid(VALUE self
, VALUE p_value
, VALUE mi_value
)
1750 char *p
= StringValuePtr(p_value
);
1751 int ix
= NUM2INT(rb_funcall(mi_value
, rb_intern("index"), 0));
1752 int smokeidx
= NUM2INT(rb_funcall(mi_value
, rb_intern("smoke"), 0));
1753 Smoke::ModuleIndex mi
= { smokeList
[smokeidx
], ix
};
1754 classcache
.insert(QByteArray(p
), new Smoke::ModuleIndex(mi
));
1755 IdToClassNameMap
.insert(mi
, new QByteArray(p
));
1760 classid2name(VALUE
/*self*/, VALUE mi_value
)
1762 int ix
= NUM2INT(rb_funcall(mi_value
, rb_intern("index"), 0));
1763 int smokeidx
= NUM2INT(rb_funcall(mi_value
, rb_intern("smoke"), 0));
1764 Smoke::ModuleIndex mi
= { smokeList
[smokeidx
], ix
};
1765 return rb_str_new2(IdToClassNameMap
[mi
]->constData());
1769 find_pclassid(VALUE
/*self*/, VALUE p_value
)
1771 char *p
= StringValuePtr(p_value
);
1772 Smoke::ModuleIndex
*r
= classcache
.value(QByteArray(p
));
1774 return rb_funcall(moduleindex_class
, rb_intern("new"), 2, INT2NUM(smokeList
.indexOf(r
->smoke
)), INT2NUM(r
->index
));
1776 return rb_funcall(moduleindex_class
, rb_intern("new"), 2, 0, 0);
1781 get_value_type(VALUE
/*self*/, VALUE ruby_value
)
1783 return rb_str_new2(value_to_type_flag(ruby_value
));
1787 parent_meta_object(VALUE obj
)
1789 smokeruby_object
* o
= value_obj_info(obj
);
1790 Smoke::ModuleIndex nameId
= o
->smoke
->idMethodName("metaObject");
1791 Smoke::ModuleIndex classIdx
= { o
->smoke
, o
->classId
};
1792 Smoke::ModuleIndex meth
= o
->smoke
->findMethod(classIdx
, nameId
);
1793 if (meth
.index
<= 0) {
1794 // Should never happen..
1797 Smoke::Method
&methodId
= meth
.smoke
->methods
[meth
.smoke
->methodMaps
[meth
.index
].method
];
1798 Smoke::ClassFn fn
= o
->smoke
->classes
[methodId
.classId
].classFn
;
1799 Smoke::StackItem i
[1];
1800 (*fn
)(methodId
.method
, o
->ptr
, i
);
1801 return (QMetaObject
*) i
[0].s_voidp
;
1805 make_metaObject(VALUE
/*self*/, VALUE obj
, VALUE parentMeta
, VALUE stringdata_value
, VALUE data_value
)
1807 QMetaObject
* superdata
= 0;
1809 if (parentMeta
== Qnil
) {
1810 // The parent class is a Smoke class, so call metaObject() on the
1811 // instance to get it via a smoke library call
1812 superdata
= parent_meta_object(obj
);
1814 // The parent class is a custom Ruby class whose metaObject
1815 // was constructed at runtime
1816 smokeruby_object
* p
= value_obj_info(parentMeta
);
1817 superdata
= (QMetaObject
*) p
->ptr
;
1820 char *stringdata
= new char[RSTRING_LEN(stringdata_value
)];
1822 int count
= RARRAY_LEN(data_value
);
1823 uint
* data
= new uint
[count
];
1825 memcpy( (void *) stringdata
, RSTRING_PTR(stringdata_value
), RSTRING_LEN(stringdata_value
) );
1827 for (long i
= 0; i
< count
; i
++) {
1828 VALUE rv
= rb_ary_entry(data_value
, i
);
1829 data
[i
] = NUM2UINT(rv
);
1833 { superdata
, stringdata
, data
, 0 }
1836 QMetaObject
* meta
= new QMetaObject
;
1840 printf("make_metaObject() superdata: %p %s\n", meta
->d
.superdata
, superdata
->className());
1844 " %d, // revision\n"
1845 " %d, // classname\n"
1846 " %d, %d, // classinfo\n"
1847 " %d, %d, // methods\n"
1848 " %d, %d, // properties\n"
1849 " %d, %d, // enums/sets\n",
1850 data
[0], data
[1], data
[2], data
[3],
1851 data
[4], data
[5], data
[6], data
[7], data
[8], data
[9]);
1856 printf("\n // classinfo: key, value\n");
1857 for (uint j
= 0; j
< data
[2]; j
++) {
1858 printf(" %d, %d\n", data
[s
+ (j
* 2)], data
[s
+ (j
* 2) + 1]);
1863 bool signal_headings
= true;
1864 bool slot_headings
= true;
1866 for (uint j
= 0; j
< data
[4]; j
++) {
1867 if (signal_headings
&& (data
[s
+ (j
* 5) + 4] & 0x04) != 0) {
1868 printf("\n // signals: signature, parameters, type, tag, flags\n");
1869 signal_headings
= false;
1872 if (slot_headings
&& (data
[s
+ (j
* 5) + 4] & 0x08) != 0) {
1873 printf("\n // slots: signature, parameters, type, tag, flags\n");
1874 slot_headings
= false;
1877 printf(" %d, %d, %d, %d, 0x%2.2x\n",
1878 data
[s
+ (j
* 5)], data
[s
+ (j
* 5) + 1], data
[s
+ (j
* 5) + 2],
1879 data
[s
+ (j
* 5) + 3], data
[s
+ (j
* 5) + 4]);
1883 for (uint j
= 0; j
< data
[6]; j
++) {
1884 printf("\n // properties: name, type, flags\n");
1885 printf(" %d, %d, 0x%8.8x\n",
1886 data
[s
+ (j
* 3)], data
[s
+ (j
* 3) + 1], data
[s
+ (j
* 3) + 2]);
1890 for (int i
= s
; i
< count
; i
++) {
1891 printf("\n %d // eod\n", data
[i
]);
1894 printf("\nqt_meta_stringdata:\n \"");
1897 for (int j
= 0; j
< RSTRING_LEN(stringdata_value
); j
++) {
1899 if (meta
->d
.stringdata
[j
] == 0) {
1901 if (strlength
> 40) {
1906 printf("%c", meta
->d
.stringdata
[j
]);
1912 smokeruby_object
* m
= alloc_smokeruby_object( true,
1914 qt_Smoke
->idClass("QMetaObject").index
,
1917 return Data_Wrap_Struct(qmetaobject_class
, smokeruby_mark
, smokeruby_free
, m
);
1921 add_metaobject_methods(VALUE self
, VALUE klass
)
1923 rb_define_method(klass
, "qt_metacall", (VALUE (*) (...)) qt_metacall
, -1);
1924 rb_define_method(klass
, "metaObject", (VALUE (*) (...)) metaObject
, 0);
1929 add_signal_methods(VALUE self
, VALUE klass
, VALUE signalNames
)
1931 for (long index
= 0; index
< RARRAY_LEN(signalNames
); index
++) {
1932 VALUE signal
= rb_ary_entry(signalNames
, index
);
1933 rb_define_method(klass
, StringValuePtr(signal
), (VALUE (*) (...)) qt_signal
, -1);
1941 smokeruby_object
*o
= value_obj_info(self
);
1942 if (o
== 0 || o
->ptr
== 0) { return Qnil
; }
1944 const char *className
= o
->smoke
->classes
[o
->classId
].className
;
1945 if(do_debug
& qtdb_gc
) printf("Deleting (%s*)%p\n", className
, o
->ptr
);
1947 unmapPointer(o
, o
->classId
, 0);
1950 char *methodName
= new char[strlen(className
) + 2];
1951 methodName
[0] = '~';
1952 strcpy(methodName
+ 1, className
);
1953 Smoke::ModuleIndex nameId
= o
->smoke
->findMethodName(className
, methodName
);
1954 Smoke::ModuleIndex classIdx
= { o
->smoke
, o
->classId
};
1955 Smoke::ModuleIndex meth
= nameId
.smoke
->findMethod(classIdx
, nameId
);
1956 if(meth
.index
> 0) {
1957 Smoke::Method
&m
= meth
.smoke
->methods
[meth
.smoke
->methodMaps
[meth
.index
].method
];
1958 Smoke::ClassFn fn
= meth
.smoke
->classes
[m
.classId
].classFn
;
1959 Smoke::StackItem i
[1];
1960 (*fn
)(m
.method
, o
->ptr
, i
);
1962 delete[] methodName
;
1964 o
->allocated
= false;
1970 is_disposed(VALUE self
)
1972 smokeruby_object
*o
= value_obj_info(self
);
1973 return (o
!= 0 && o
->ptr
!= 0) ? Qfalse
: Qtrue
;
1977 isQObject(VALUE
/*self*/, VALUE c
)
1979 const char* classname
= strdup(StringValuePtr(c
));
1981 return qt_Smoke
->isDerivedFromByName(classname
, "QObject");
1983 free((void*) classname
);
1986 // Returns the Smoke classId of a ruby instance
1988 idInstance(VALUE
/*self*/, VALUE instance
)
1990 smokeruby_object
*o
= value_obj_info(instance
);
1994 return rb_funcall(moduleindex_class
, rb_intern("new"), 2, INT2NUM(smokeList
.indexOf(o
->smoke
)), INT2NUM(o
->classId
));
1998 findClass(VALUE
/*self*/, VALUE name_value
)
2000 char *name
= StringValuePtr(name_value
);
2001 Smoke::ModuleIndex mi
= qt_Smoke
->findClass(name
);
2002 return rb_funcall(moduleindex_class
, rb_intern("new"), 2, INT2NUM(smokeList
.indexOf(mi
.smoke
)), INT2NUM(mi
.index
));
2006 // idMethodName(VALUE /*self*/, VALUE name_value)
2008 // char *name = StringValuePtr(name_value);
2009 // return INT2NUM(qt_Smoke->idMethodName(name).index);
2013 // idMethod(VALUE /*self*/, VALUE idclass_value, VALUE idmethodname_value)
2015 // int idclass = NUM2INT(idclass_value);
2016 // int idmethodname = NUM2INT(idmethodname_value);
2017 // return INT2NUM(qt_Smoke->idMethod(idclass, idmethodname).index);
2021 dumpCandidates(VALUE
/*self*/, VALUE rmeths
)
2023 VALUE errmsg
= rb_str_new2("");
2024 if(rmeths
!= Qnil
) {
2025 int count
= RARRAY_LEN(rmeths
);
2026 for(int i
= 0; i
< count
; i
++) {
2027 rb_str_catf(errmsg
, "\t");
2028 int id
= NUM2INT(rb_funcall(rb_ary_entry(rmeths
, i
), rb_intern("index"), 0));
2029 Smoke
* smoke
= smokeList
[NUM2INT(rb_funcall(rb_ary_entry(rmeths
, i
), rb_intern("smoke"), 0))];
2030 Smoke::Method
&meth
= smoke
->methods
[id
];
2031 const char *tname
= smoke
->types
[meth
.ret
].name
;
2032 if(meth
.flags
& Smoke::mf_enum
) {
2033 rb_str_catf(errmsg
, "enum ");
2034 rb_str_catf(errmsg
, "%s::%s", smoke
->classes
[meth
.classId
].className
, smoke
->methodNames
[meth
.name
]);
2035 rb_str_catf(errmsg
, "\n");
2037 if(meth
.flags
& Smoke::mf_static
) rb_str_catf(errmsg
, "static ");
2038 rb_str_catf(errmsg
, "%s ", (tname
? tname
:"void"));
2039 rb_str_catf(errmsg
, "%s::%s(", smoke
->classes
[meth
.classId
].className
, smoke
->methodNames
[meth
.name
]);
2040 for(int i
= 0; i
< meth
.numArgs
; i
++) {
2041 if(i
) rb_str_catf(errmsg
, ", ");
2042 tname
= smoke
->types
[smoke
->argumentList
[meth
.args
+i
]].name
;
2043 rb_str_catf(errmsg
, "%s", (tname
? tname
:"void"));
2045 rb_str_catf(errmsg
, ")");
2046 if(meth
.flags
& Smoke::mf_const
) rb_str_catf(errmsg
, " const");
2047 rb_str_catf(errmsg
, "\n");
2055 isObject(VALUE
/*self*/, VALUE obj
)
2058 ptr
= value_to_ptr(obj
);
2059 return (ptr
> 0 ? Qtrue
: Qfalse
);
2063 setCurrentMethod(VALUE self
, VALUE meth_value
)
2065 int smokeidx
= NUM2INT(rb_funcall(meth_value
, rb_intern("smoke"), 0));
2066 int meth
= NUM2INT(rb_funcall(meth_value
, rb_intern("index"), 0));
2067 // FIXME: damn, this is lame, and it doesn't handle ambiguous methods
2068 _current_method
.smoke
= smokeList
[smokeidx
]; //qt_Smoke->methodMaps[meth].method;
2069 _current_method
.index
= meth
;
2074 getClassList(VALUE
/*self*/)
2076 VALUE class_list
= rb_ary_new();
2078 for (int i
= 1; i
<= qt_Smoke
->numClasses
; i
++) {
2079 if (qt_Smoke
->classes
[i
].className
)
2080 rb_ary_push(class_list
, rb_str_new2(qt_Smoke
->classes
[i
].className
));
2087 create_qobject_class(VALUE
/*self*/, VALUE package_value
, VALUE module_value
)
2089 const char *package
= strdup(StringValuePtr(package_value
));
2091 // strdup(StringValuePtr(rb_funcall(module_value, rb_intern("name"), 0)))
2093 VALUE value_moduleName
= rb_funcall(module_value
, rb_intern("name"), 0);
2094 const char *moduleName
= strdup(StringValuePtr(value_moduleName
));
2095 VALUE klass
= module_value
;
2097 QString
packageName(package
);
2099 foreach(QString s
, packageName
.mid(strlen(moduleName
) + 2).split("::")) {
2100 klass
= rb_define_class_under(klass
, (const char*) s
.toLatin1(), qt_base_class
);
2103 if (packageName
== "Qt::Application" || packageName
== "Qt::CoreApplication" ) {
2104 rb_define_method(klass
, "ARGV", (VALUE (*) (...)) qapplication_argv
, 0);
2105 } else if (packageName
== "Qt::Object") {
2106 rb_define_singleton_method(klass
, "staticMetaObject", (VALUE (*) (...)) qobject_staticmetaobject
, 0);
2107 } else if (packageName
== "Qt::AbstractTableModel") {
2108 qtablemodel_class
= rb_define_class_under(qt_module
, "TableModel", klass
);
2109 rb_define_method(qtablemodel_class
, "rowCount", (VALUE (*) (...)) qabstract_item_model_rowcount
, -1);
2110 rb_define_method(qtablemodel_class
, "row_count", (VALUE (*) (...)) qabstract_item_model_rowcount
, -1);
2111 rb_define_method(qtablemodel_class
, "columnCount", (VALUE (*) (...)) qabstract_item_model_columncount
, -1);
2112 rb_define_method(qtablemodel_class
, "column_count", (VALUE (*) (...)) qabstract_item_model_columncount
, -1);
2113 rb_define_method(qtablemodel_class
, "data", (VALUE (*) (...)) qabstract_item_model_data
, -1);
2114 rb_define_method(qtablemodel_class
, "setData", (VALUE (*) (...)) qabstract_item_model_setdata
, -1);
2115 rb_define_method(qtablemodel_class
, "set_data", (VALUE (*) (...)) qabstract_item_model_setdata
, -1);
2116 rb_define_method(qtablemodel_class
, "flags", (VALUE (*) (...)) qabstract_item_model_flags
, 1);
2117 rb_define_method(qtablemodel_class
, "insertRows", (VALUE (*) (...)) qabstract_item_model_insertrows
, -1);
2118 rb_define_method(qtablemodel_class
, "insert_rows", (VALUE (*) (...)) qabstract_item_model_insertrows
, -1);
2119 rb_define_method(qtablemodel_class
, "insertColumns", (VALUE (*) (...)) qabstract_item_model_insertcolumns
, -1);
2120 rb_define_method(qtablemodel_class
, "insert_columns", (VALUE (*) (...)) qabstract_item_model_insertcolumns
, -1);
2121 rb_define_method(qtablemodel_class
, "removeRows", (VALUE (*) (...)) qabstract_item_model_removerows
, -1);
2122 rb_define_method(qtablemodel_class
, "remove_rows", (VALUE (*) (...)) qabstract_item_model_removerows
, -1);
2123 rb_define_method(qtablemodel_class
, "removeColumns", (VALUE (*) (...)) qabstract_item_model_removecolumns
, -1);
2124 rb_define_method(qtablemodel_class
, "remove_columns", (VALUE (*) (...)) qabstract_item_model_removecolumns
, -1);
2126 qlistmodel_class
= rb_define_class_under(qt_module
, "ListModel", klass
);
2127 rb_define_method(qlistmodel_class
, "rowCount", (VALUE (*) (...)) qabstract_item_model_rowcount
, -1);
2128 rb_define_method(qlistmodel_class
, "row_count", (VALUE (*) (...)) qabstract_item_model_rowcount
, -1);
2129 rb_define_method(qlistmodel_class
, "columnCount", (VALUE (*) (...)) qabstract_item_model_columncount
, -1);
2130 rb_define_method(qlistmodel_class
, "column_count", (VALUE (*) (...)) qabstract_item_model_columncount
, -1);
2131 rb_define_method(qlistmodel_class
, "data", (VALUE (*) (...)) qabstract_item_model_data
, -1);
2132 rb_define_method(qlistmodel_class
, "setData", (VALUE (*) (...)) qabstract_item_model_setdata
, -1);
2133 rb_define_method(qlistmodel_class
, "set_data", (VALUE (*) (...)) qabstract_item_model_setdata
, -1);
2134 rb_define_method(qlistmodel_class
, "flags", (VALUE (*) (...)) qabstract_item_model_flags
, 1);
2135 rb_define_method(qlistmodel_class
, "insertRows", (VALUE (*) (...)) qabstract_item_model_insertrows
, -1);
2136 rb_define_method(qlistmodel_class
, "insert_rows", (VALUE (*) (...)) qabstract_item_model_insertrows
, -1);
2137 rb_define_method(qlistmodel_class
, "insertColumns", (VALUE (*) (...)) qabstract_item_model_insertcolumns
, -1);
2138 rb_define_method(qlistmodel_class
, "insert_columns", (VALUE (*) (...)) qabstract_item_model_insertcolumns
, -1);
2139 rb_define_method(qlistmodel_class
, "removeRows", (VALUE (*) (...)) qabstract_item_model_removerows
, -1);
2140 rb_define_method(qlistmodel_class
, "remove_rows", (VALUE (*) (...)) qabstract_item_model_removerows
, -1);
2141 rb_define_method(qlistmodel_class
, "removeColumns", (VALUE (*) (...)) qabstract_item_model_removecolumns
, -1);
2142 rb_define_method(qlistmodel_class
, "remove_columns", (VALUE (*) (...)) qabstract_item_model_removecolumns
, -1);
2144 else if (packageName
== "Qt::AbstractItemModel") {
2145 rb_define_method(klass
, "createIndex", (VALUE (*) (...)) qabstractitemmodel_createindex
, -1);
2146 rb_define_method(klass
, "create_index", (VALUE (*) (...)) qabstractitemmodel_createindex
, -1);
2147 } else if (packageName
== "Qt::Timer") {
2148 rb_define_singleton_method(klass
, "singleShot", (VALUE (*) (...)) qtimer_single_shot
, -1);
2149 rb_define_singleton_method(klass
, "single_shot", (VALUE (*) (...)) qtimer_single_shot
, -1);
2153 rb_define_method(klass
, "qobject_cast", (VALUE (*) (...)) qobject_qt_metacast
, 1);
2154 rb_define_method(klass
, "inspect", (VALUE (*) (...)) inspect_qobject
, 0);
2155 rb_define_method(klass
, "pretty_print", (VALUE (*) (...)) pretty_print_qobject
, 1);
2156 rb_define_method(klass
, "className", (VALUE (*) (...)) class_name
, 0);
2157 rb_define_method(klass
, "class_name", (VALUE (*) (...)) class_name
, 0);
2158 rb_define_method(klass
, "inherits", (VALUE (*) (...)) inherits_qobject
, -1);
2159 rb_define_method(klass
, "findChildren", (VALUE (*) (...)) find_qobject_children
, -1);
2160 rb_define_method(klass
, "find_children", (VALUE (*) (...)) find_qobject_children
, -1);
2161 rb_define_method(klass
, "findChild", (VALUE (*) (...)) find_qobject_child
, -1);
2162 rb_define_method(klass
, "find_child", (VALUE (*) (...)) find_qobject_child
, -1);
2163 rb_define_method(klass
, "connect", (VALUE (*) (...)) qobject_connect
, -1);
2164 rb_define_singleton_method(klass
, "connect", (VALUE (*) (...)) qobject_connect
, -1);
2166 foreach(QtRubyModule m
, qtruby_modules
.values()) {
2167 if (m
.class_created
)
2168 m
.class_created(package
, module_value
, klass
);
2171 free((void *) package
);
2176 create_qt_class(VALUE
/*self*/, VALUE package_value
, VALUE module_value
)
2178 const char *package
= strdup(StringValuePtr(package_value
));
2180 // strdup(StringValuePtr(rb_funcall(module_value, rb_intern("name"), 0)))
2182 VALUE value_moduleName
= rb_funcall(module_value
, rb_intern("name"), 0);
2183 const char *moduleName
= strdup(StringValuePtr(value_moduleName
));
2184 VALUE klass
= module_value
;
2185 QString
packageName(package
);
2187 rb_define_singleton_method(module_value
, "method_missing", (VALUE (*) (...)) module_method_missing
, -1);
2188 rb_define_singleton_method(module_value
, "const_missing", (VALUE (*) (...)) module_method_missing
, -1);
2190 foreach(QString s
, packageName
.mid(strlen(moduleName
) + 2).split("::")) {
2191 klass
= rb_define_class_under(klass
, (const char*) s
.toLatin1(), qt_base_class
);
2194 if (packageName
== "Qt::MetaObject") {
2195 qmetaobject_class
= klass
;
2196 } else if (packageName
== "Qt::Variant") {
2197 qvariant_class
= klass
;
2198 rb_define_singleton_method(qvariant_class
, "fromValue", (VALUE (*) (...)) qvariant_from_value
, -1);
2199 rb_define_singleton_method(qvariant_class
, "from_value", (VALUE (*) (...)) qvariant_from_value
, -1);
2200 rb_define_singleton_method(qvariant_class
, "new", (VALUE (*) (...)) new_qvariant
, -1);
2201 } else if (packageName
== "Qt::ByteArray") {
2202 rb_define_method(klass
, "+", (VALUE (*) (...)) qbytearray_append
, 1);
2203 rb_define_method(klass
, "data", (VALUE (*) (...)) qbytearray_data
, 0);
2204 rb_define_method(klass
, "constData", (VALUE (*) (...)) qbytearray_data
, 0);
2205 rb_define_method(klass
, "const_data", (VALUE (*) (...)) qbytearray_data
, 0);
2206 } else if (packageName
== "Qt::Char") {
2207 rb_define_method(klass
, "to_s", (VALUE (*) (...)) qchar_to_s
, 0);
2208 } else if (packageName
== "Qt::Image") {
2209 rb_define_method(klass
, "bits", (VALUE (*) (...)) qimage_bits
, 0);
2210 rb_define_method(klass
, "scanLine", (VALUE (*) (...)) qimage_scan_line
, 1);
2211 } else if (packageName
== "Qt::ItemSelection") {
2212 rb_define_method(klass
, "[]", (VALUE (*) (...)) qitemselection_at
, 1);
2213 rb_define_method(klass
, "at", (VALUE (*) (...)) qitemselection_at
, 1);
2214 rb_define_method(klass
, "count", (VALUE (*) (...)) qitemselection_count
, 0);
2215 rb_define_method(klass
, "length", (VALUE (*) (...)) qitemselection_count
, 0);
2216 } else if (packageName
== "Qt::Painter") {
2217 rb_define_method(klass
, "drawLines", (VALUE (*) (...)) qpainter_drawlines
, -1);
2218 rb_define_method(klass
, "draw_lines", (VALUE (*) (...)) qpainter_drawlines
, -1);
2219 rb_define_method(klass
, "drawRects", (VALUE (*) (...)) qpainter_drawrects
, -1);
2220 rb_define_method(klass
, "draw_rects", (VALUE (*) (...)) qpainter_drawrects
, -1);
2221 } else if (packageName
== "Qt::ModelIndex") {
2222 rb_define_method(klass
, "internalPointer", (VALUE (*) (...)) qmodelindex_internalpointer
, 0);
2223 rb_define_method(klass
, "internal_pointer", (VALUE (*) (...)) qmodelindex_internalpointer
, 0);
2224 } else if (packageName
== "Qt::SignalMapper") {
2225 rb_define_method(klass
, "mapping", (VALUE (*) (...)) qsignalmapper_mapping
, -1);
2226 rb_define_method(klass
, "setMapping", (VALUE (*) (...)) qsignalmapper_set_mapping
, -1);
2227 rb_define_method(klass
, "set_mapping", (VALUE (*) (...)) qsignalmapper_set_mapping
, -1);
2229 } else if (packageName
== "Qt::DBusArgument") {
2230 rb_define_method(klass
, "endArrayWrite", (VALUE (*) (...)) qdbusargument_endarraywrite
, 0);
2231 rb_define_method(klass
, "end_array_write", (VALUE (*) (...)) qdbusargument_endarraywrite
, 0);
2232 rb_define_method(klass
, "endMapEntryWrite", (VALUE (*) (...)) qdbusargument_endmapentrywrite
, 0);
2233 rb_define_method(klass
, "end_map_entry_write", (VALUE (*) (...)) qdbusargument_endmapentrywrite
, 0);
2234 rb_define_method(klass
, "endMapWrite", (VALUE (*) (...)) qdbusargument_endmapwrite
, 0);
2235 rb_define_method(klass
, "end_map_write", (VALUE (*) (...)) qdbusargument_endmapwrite
, 0);
2236 rb_define_method(klass
, "endStructureWrite", (VALUE (*) (...)) qdbusargument_endstructurewrite
, 0);
2237 rb_define_method(klass
, "end_structure_write", (VALUE (*) (...)) qdbusargument_endstructurewrite
, 0);
2241 foreach(QtRubyModule m
, qtruby_modules
.values()) {
2242 if (m
.class_created
)
2243 m
.class_created(package
, module_value
, klass
);
2246 free((void *) package
);
2251 version(VALUE
/*self*/)
2253 return rb_str_new2(QT_VERSION_STR
);
2257 qtruby_version(VALUE
/*self*/)
2259 return rb_str_new2(QTRUBY_VERSION
);
2263 set_application_terminated(VALUE
/*self*/, VALUE yn
)
2265 application_terminated
= (yn
== Qtrue
? true : false);
2270 set_qtruby_embedded_wrapped(VALUE
/*self*/, VALUE yn
)
2272 set_qtruby_embedded( yn
== Qtrue
);
2276 static QtRuby::Binding binding
;
2278 extern Q_DECL_EXPORT
void
2281 if (qt_Smoke
== 0) init_qt_Smoke();
2282 smokeList
<< qt_Smoke
;
2284 binding
= QtRuby::Binding(qt_Smoke
);
2285 QtRubyModule module
= { "QtRuby", resolve_classname_qt
, 0, &binding
};
2286 qtruby_modules
[qt_Smoke
] = module
;
2288 install_handlers(Qt_handlers
);
2290 if (qt_module
== Qnil
) {
2291 qt_module
= rb_define_module("Qt");
2292 qt_internal_module
= rb_define_module_under(qt_module
, "Internal");
2293 qt_base_class
= rb_define_class_under(qt_module
, "Base", rb_cObject
);
2294 moduleindex_class
= rb_define_class_under(qt_internal_module
, "ModuleIndex", rb_cObject
);
2297 rb_define_singleton_method(qt_base_class
, "new", (VALUE (*) (...)) new_qt
, -1);
2298 rb_define_method(qt_base_class
, "initialize", (VALUE (*) (...)) initialize_qt
, -1);
2299 rb_define_singleton_method(qt_base_class
, "method_missing", (VALUE (*) (...)) class_method_missing
, -1);
2300 rb_define_singleton_method(qt_module
, "method_missing", (VALUE (*) (...)) module_method_missing
, -1);
2301 rb_define_method(qt_base_class
, "method_missing", (VALUE (*) (...)) method_missing
, -1);
2303 rb_define_singleton_method(qt_base_class
, "const_missing", (VALUE (*) (...)) class_method_missing
, -1);
2304 rb_define_singleton_method(qt_module
, "const_missing", (VALUE (*) (...)) module_method_missing
, -1);
2305 rb_define_method(qt_base_class
, "const_missing", (VALUE (*) (...)) method_missing
, -1);
2307 rb_define_method(qt_base_class
, "dispose", (VALUE (*) (...)) dispose
, 0);
2308 rb_define_method(qt_base_class
, "isDisposed", (VALUE (*) (...)) is_disposed
, 0);
2309 rb_define_method(qt_base_class
, "disposed?", (VALUE (*) (...)) is_disposed
, 0);
2311 rb_define_method(qt_base_class
, "qVariantValue", (VALUE (*) (...)) qvariant_value
, 2);
2312 rb_define_method(qt_base_class
, "qVariantFromValue", (VALUE (*) (...)) qvariant_from_value
, -1);
2314 rb_define_method(rb_cObject
, "qDebug", (VALUE (*) (...)) qdebug
, 1);
2315 rb_define_method(rb_cObject
, "qFatal", (VALUE (*) (...)) qfatal
, 1);
2316 rb_define_method(rb_cObject
, "qWarning", (VALUE (*) (...)) qwarning
, 1);
2318 rb_define_module_function(qt_internal_module
, "getMethStat", (VALUE (*) (...)) getMethStat
, 0);
2319 rb_define_module_function(qt_internal_module
, "getClassStat", (VALUE (*) (...)) getClassStat
, 0);
2320 rb_define_module_function(qt_internal_module
, "getIsa", (VALUE (*) (...)) getIsa
, 1);
2321 rb_define_module_function(qt_internal_module
, "setDebug", (VALUE (*) (...)) setDebug
, 1);
2322 rb_define_module_function(qt_internal_module
, "debug", (VALUE (*) (...)) debugging
, 0);
2323 rb_define_module_function(qt_internal_module
, "get_arg_type_name", (VALUE (*) (...)) get_arg_type_name
, 2);
2324 rb_define_module_function(qt_internal_module
, "classIsa", (VALUE (*) (...)) classIsa
, 2);
2325 rb_define_module_function(qt_internal_module
, "isEnum", (VALUE (*) (...)) isEnum
, 1);
2326 rb_define_module_function(qt_internal_module
, "insert_pclassid", (VALUE (*) (...)) insert_pclassid
, 2);
2327 rb_define_module_function(qt_internal_module
, "classid2name", (VALUE (*) (...)) classid2name
, 1);
2328 rb_define_module_function(qt_internal_module
, "find_pclassid", (VALUE (*) (...)) find_pclassid
, 1);
2329 rb_define_module_function(qt_internal_module
, "get_value_type", (VALUE (*) (...)) get_value_type
, 1);
2331 rb_define_module_function(qt_internal_module
, "make_metaObject", (VALUE (*) (...)) make_metaObject
, 4);
2332 rb_define_module_function(qt_internal_module
, "addMetaObjectMethods", (VALUE (*) (...)) add_metaobject_methods
, 1);
2333 rb_define_module_function(qt_internal_module
, "addSignalMethods", (VALUE (*) (...)) add_signal_methods
, 2);
2334 rb_define_module_function(qt_internal_module
, "mapObject", (VALUE (*) (...)) mapObject
, 1);
2336 rb_define_module_function(qt_internal_module
, "isQObject", (VALUE (*) (...)) isQObject
, 1);
2337 rb_define_module_function(qt_internal_module
, "idInstance", (VALUE (*) (...)) idInstance
, 1);
2338 rb_define_module_function(qt_internal_module
, "findClass", (VALUE (*) (...)) findClass
, 1);
2339 // rb_define_module_function(qt_internal_module, "idMethodName", (VALUE (*) (...)) idMethodName, 1);
2340 // rb_define_module_function(qt_internal_module, "idMethod", (VALUE (*) (...)) idMethod, 2);
2341 rb_define_module_function(qt_internal_module
, "findMethod", (VALUE (*) (...)) findMethod
, 2);
2342 rb_define_module_function(qt_internal_module
, "findAllMethods", (VALUE (*) (...)) findAllMethods
, -1);
2343 rb_define_module_function(qt_internal_module
, "findAllMethodNames", (VALUE (*) (...)) findAllMethodNames
, 3);
2344 rb_define_module_function(qt_internal_module
, "dumpCandidates", (VALUE (*) (...)) dumpCandidates
, 1);
2345 rb_define_module_function(qt_internal_module
, "isObject", (VALUE (*) (...)) isObject
, 1);
2346 rb_define_module_function(qt_internal_module
, "setCurrentMethod", (VALUE (*) (...)) setCurrentMethod
, 1);
2347 rb_define_module_function(qt_internal_module
, "getClassList", (VALUE (*) (...)) getClassList
, 0);
2348 rb_define_module_function(qt_internal_module
, "create_qt_class", (VALUE (*) (...)) create_qt_class
, 2);
2349 rb_define_module_function(qt_internal_module
, "create_qobject_class", (VALUE (*) (...)) create_qobject_class
, 2);
2350 rb_define_module_function(qt_internal_module
, "cast_object_to", (VALUE (*) (...)) cast_object_to
, 2);
2351 rb_define_module_function(qt_module
, "dynamic_cast", (VALUE (*) (...)) cast_object_to
, 2);
2352 rb_define_module_function(qt_internal_module
, "kross2smoke", (VALUE (*) (...)) kross2smoke
, 2);
2353 rb_define_module_function(qt_internal_module
, "set_qtruby_embedded", (VALUE (*) (...)) set_qtruby_embedded_wrapped
, 1);
2355 rb_define_module_function(qt_internal_module
, "application_terminated=", (VALUE (*) (...)) set_application_terminated
, 1);
2357 rb_define_module_function(qt_module
, "version", (VALUE (*) (...)) version
, 0);
2358 rb_define_module_function(qt_module
, "qtruby_version", (VALUE (*) (...)) qtruby_version
, 0);
2360 rb_define_module_function(qt_module
, "qRegisterResourceData", (VALUE (*) (...)) q_register_resource_data
, 4);
2361 rb_define_module_function(qt_module
, "qUnregisterResourceData", (VALUE (*) (...)) q_unregister_resource_data
, 4);
2363 rb_require("Qt/qtruby4.rb");
2365 // Do package initialization
2366 rb_funcall(qt_internal_module
, rb_intern("init_all_classes"), 0);
2370 // kate: space-indent false;