0 | |
From cc551d8feeed74ee923c53587ee08859560c3300 Mon Sep 17 00:00:00 2001
|
1 | |
From: Pino Toscano <pino@kde.org>
|
2 | |
Date: Fri, 10 Jan 2014 09:19:13 +0100
|
3 | |
Subject: [PATCH] ruby: fix rb_raise calls with arguments
|
4 | |
|
5 | |
When passing arguments to the error string for rb_raise, just pass them
|
6 | |
to rb_raise directly (which takes printf-like varargs) instead of
|
7 | |
building a QString manually
|
8 | |
---
|
9 | |
ruby/rubyextension.cpp | 12 ++++++------
|
10 | |
1 file changed, 6 insertions(+), 6 deletions(-)
|
11 | |
|
12 | |
diff --git a/ruby/rubyextension.cpp b/ruby/rubyextension.cpp
|
13 | |
index 9afbbb2..7630058 100644
|
14 | |
--- a/ruby/rubyextension.cpp
|
15 | |
+++ b/ruby/rubyextension.cpp
|
16 | |
@@ -278,7 +278,7 @@ VALUE RubyExtension::callConnect(int argc, VALUE *argv, VALUE self)
|
17 | |
sendersignal = RubyType<QByteArray>::toVariant(argv[1]);
|
18 | |
idx = 2;
|
19 | |
if( argc <= idx ) {
|
20 | |
- rb_raise(rb_eTypeError, ::QString("Expected at least %1 arguments.").arg(idx+1).toLatin1().constData());
|
21 | |
+ rb_raise(rb_eTypeError, "Expected at least %d arguments.", idx+1);
|
22 | |
return Qfalse;
|
23 | |
}
|
24 | |
} break;
|
25 | |
@@ -310,7 +310,7 @@ VALUE RubyExtension::callConnect(int argc, VALUE *argv, VALUE self)
|
26 | |
*/
|
27 | |
#if(!(RUBY_API_VERSION_MAJOR==1 && RUBY_API_VERSION_MINOR==8 && RUBY_API_VERSION_TEENY==4))
|
28 | |
else {
|
29 | |
- rb_raise(rb_eTypeError, ::QString("The argument number %1 is invalid.").arg(idx).toLatin1().constData());
|
30 | |
+ rb_raise(rb_eTypeError, "The argument number %d is invalid.", idx);
|
31 | |
return Qfalse;
|
32 | |
}
|
33 | |
#endif
|
34 | |
@@ -462,19 +462,19 @@ VALUE RubyExtension::call_method_missing(RubyExtension* extension, int argc, VAL
|
35 | |
QMetaProperty property = metaobject->property( extension->d->m_properties[name] );
|
36 | |
if( name.endsWith('=') ) { // setter
|
37 | |
if(argc < 2) {
|
38 | |
- rb_raise(rb_eNameError, QString("Expected value-argument for \"%1\" setter.").arg(name.constData()).toLatin1().constData());
|
39 | |
+ rb_raise(rb_eNameError, "Expected value-argument for \"%s\" setter.", name.constData());
|
40 | |
return Qnil;
|
41 | |
}
|
42 | |
QVariant v = RubyType<QVariant>::toVariant(argv[1]);
|
43 | |
if(! property.write(extension->d->m_object, v)) {
|
44 | |
- rb_raise(rb_eNameError, QString("Setting attribute \"%1\" failed.").arg(name.constData()).toLatin1().constData());
|
45 | |
+ rb_raise(rb_eNameError, "Setting attribute \"%s\" failed.", name.constData());
|
46 | |
return Qnil;
|
47 | |
}
|
48 | |
return Qnil;
|
49 | |
}
|
50 | |
else { // getter
|
51 | |
if(! property.isReadable()) {
|
52 | |
- rb_raise(rb_eNameError, QString("Attribute \"%1\" is not readable.").arg(name.constData()).toLatin1().constData());
|
53 | |
+ rb_raise(rb_eNameError, "Attribute \"%s\" is not readable.", name.constData());
|
54 | |
return Qnil;
|
55 | |
}
|
56 | |
return RubyType<QVariant>::toVALUE( property.read(extension->d->m_object) );
|
57 | |
@@ -497,7 +497,7 @@ VALUE RubyExtension::call_method_missing(RubyExtension* extension, int argc, VAL
|
58 | |
return RubyExtension::toVALUE( new RubyExtension(object), true /*owner*/ );
|
59 | |
}
|
60 | |
|
61 | |
- rb_raise(rb_eNameError, QString("No such method or variable \"%1\".").arg(name.constData()).toLatin1().constData());
|
62 | |
+ rb_raise(rb_eNameError, "No such method or variable \"%s\".", name.constData());
|
63 | |
return Qnil;
|
64 | |
}
|
65 | |
|
66 | |
--
|
67 | |
1.8.5.2
|
68 | |
|