[Kde-bindings] KDE/kdebindings/ruby/solid
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Fri Apr 24 15:47:12 UTC 2009
SVN commit 958766 by rdale:
* Instead of passing Solid::DeviceInterface::Type enums by value, the Solid api
passes them as const references. So they need special casing. Thanks to David
Palacio for pointing out the problem
CCMAIL: kde-bindings at kde.org
M +45 -0 solidhandlers.cpp
--- trunk/KDE/kdebindings/ruby/solid/solidhandlers.cpp #958765:958766
@@ -23,9 +23,54 @@
#include <solid/device.h>
+void marshall_SolidDeviceInterfaceType(Marshall *m) {
+ switch(m->action()) {
+
+ case Marshall::FromVALUE:
+ {
+ VALUE v = *(m->var());
+
+ if (v == Qnil) {
+ m->item().s_voidp = 0;
+ } else if (TYPE(v) == T_OBJECT) {
+ // Both Qt::Enum and Qt::Integer have a value() method, so 'get_qinteger()' can be called ok
+ VALUE temp = rb_funcall(qt_internal_module, rb_intern("get_qinteger"), 1, v);
+ m->item().s_voidp = new long((long) NUM2LONG(temp));
+ } else {
+ m->item().s_voidp = new long(NUM2LONG(v));
+ }
+
+ m->next();
+ if (m->item().s_voidp != 0) {
+ delete (long*) m->item().s_voidp;
+ }
+ }
+ break;
+
+ case Marshall::ToVALUE:
+ {
+ void * ptr = m->item().s_voidp;
+ if (ptr == 0) {
+ *(m->var()) = Qnil;
+ } else {
+ *(m->var()) = rb_funcall(qt_internal_module, rb_intern("create_qenum"),
+ 2, LONG2NUM(*((long *) ptr)), rb_str_new2(m->type().name()) );
+ }
+ }
+ break;
+
+ default:
+ m->unsupported();
+ break;
+ }
+}
+
DEF_VALUELIST_MARSHALLER( SolidDeviceList, QList<Solid::Device>, Solid::Device )
TypeHandler Solid_handlers[] = {
{ "QList<Solid::Device>", marshall_SolidDeviceList },
+ { "Solid::DeviceInterface::Type", marshall_SolidDeviceInterfaceType },
+ { "Solid::DeviceInterface::Type&", marshall_SolidDeviceInterfaceType },
+
{ 0, 0 }
};
More information about the Kde-bindings
mailing list