[Kde-bindings] KDE/kdebindings/ruby/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Apr 29 18:22:06 UTC 2008
SVN commit 802524 by rdale:
* Added a marshaller for references to unsigned ints
* Added initialization for the various KDE::ConfigSkeleton classes
CCMAIL: kde-bindings at kde.org
M +5 -0 ChangeLog
M +21 -1 src/Qt.cpp
M +3 -0 src/handlers.cpp
M +4 -0 src/lib/Qt/qtruby4.rb
M +46 -0 src/marshall_complex.h
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #802523:802524
@@ -1,3 +1,8 @@
+2008-04-29 Richard Dale <richard.j.dale at gmail.com>
+
+ * Added a marshaller for references to unsigned ints
+ * Added initialization for the various KDE::ConfigSkeleton classes
+
2008-04-24 Richard Dale <richard.j.dale at gmail.com>
* Fixed a couple of differences between C++ code generation and Ruby.
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #802523:802524
@@ -128,6 +128,10 @@
VALUE kconfiggroup_class = Qnil;
+VALUE kcoreconfigskeleton_class = Qnil;
+VALUE kconfigskeleton_class = Qnil;
+VALUE kconfigskeleton_itemenum_class = Qnil;
+VALUE kconfigskeleton_itemenum_choice_class = Qnil;
VALUE konsole_part_class = Qnil;
VALUE kwin_class = Qnil;
VALUE kdatetime_class = Qnil;
@@ -3151,7 +3155,19 @@
scope_op = new QRegExp("^([^:]+)::([^:]+)$");
}
- if (packageName.startsWith("KDE::Win::")) {
+ if (packageName.startsWith("KDE::ConfigSkeleton::ItemEnum::")) {
+ klass = rb_define_class_under(kconfigskeleton_itemenum_class, package+strlen("KDE::ConfigSkeleton::ItemEnum::"), base_class);
+ rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
+ kconfigskeleton_itemenum_choice_class = klass;
+ } else if (packageName.startsWith("KDE::CoreConfigSkeleton::")) {
+ // Although in C++ the class is under KCoreConfigSkeleton, the only public api is really via
+ // KConfigSkeleton. So for Ruby make them all appear under KConfigSkeleton.
+ klass = rb_define_class_under(kconfigskeleton_class, package+strlen("KDE::CoreConfigSkeleton::"), base_class);
+ rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
+ } else if (packageName.startsWith("KDE::ConfigSkeleton::")) {
+ klass = rb_define_class_under(kconfigskeleton_class, package+strlen("KDE::ConfigSkeleton::"), base_class);
+ rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
+ } else if (packageName.startsWith("KDE::Win::")) {
klass = rb_define_class_under(kwin_class, package+strlen("KDE::Win::"), base_class);
rb_define_singleton_method(klass, "new", (VALUE (*) (...)) _new_kde, -1);
} else if (packageName.startsWith("KDE::DateTime::")) {
@@ -3474,6 +3490,10 @@
nepomuk_module = rb_define_module("Nepomuk");
rb_define_singleton_method(nepomuk_module, "method_missing", (VALUE (*) (...)) kde_module_method_missing, -1);
rb_define_singleton_method(nepomuk_module, "const_missing", (VALUE (*) (...)) kde_module_method_missing, -1);
+
+ kcoreconfigskeleton_class = rb_define_class_under(kde_module, "CoreConfigSkeleton", qt_base_class);
+ kconfigskeleton_class = rb_define_class_under(kde_module, "ConfigSkeleton", qt_base_class);
+ kconfigskeleton_itemenum_class = rb_define_class_under(kconfigskeleton_class, "ItemEnum", qt_base_class);
}
static VALUE
--- trunk/KDE/kdebindings/ruby/qtruby/src/handlers.cpp #802523:802524
@@ -2506,6 +2506,9 @@
{ "QFileInfoList", marshall_QFileInfoList },
{ "QGradiantStops", marshall_QPairqrealQColor },
{ "QGradiantStops&", marshall_QPairqrealQColor },
+ { "unsigned int&", marshall_it<unsigned int *> },
+ { "quint32&", marshall_it<unsigned int *> },
+ { "uint&", marshall_it<unsigned int *> },
{ "qint32&", marshall_it<int *> },
{ "qint64", marshall_it<long long> },
{ "qint64&", marshall_it<long long> },
--- trunk/KDE/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #802523:802524
@@ -2260,6 +2260,10 @@
now = classname.sub(/^Q3(?=[A-Z])/,'Qt3::')
elsif classname =~ /^Q/
now = classname.sub(/^Q(?=[A-Z])/,'Qt::')
+ elsif classname =~ /^KCoreConfigSkeleton::/
+ # Make classes under KCoreConfigSkeleton appear under KDE::ConfigSkeleton
+ # in Ruby, as the KCoreConfigSkeleton class isn't really the public api
+ now = classname.sub(/KCore/,'KDE::')
elsif classname =~ /^(KConfigSkeleton|KWin|KDateTime|KTimeZone)::/
now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
elsif classname !~ /::/
--- trunk/KDE/kdebindings/ruby/qtruby/src/marshall_complex.h #802523:802524
@@ -82,6 +82,52 @@
}
template <>
+void marshall_from_ruby<unsigned int *>(Marshall *m)
+{
+ VALUE rv = *(m->var());
+ unsigned int *i = new unsigned int;
+
+ if (rv == Qnil) {
+ m->item().s_voidp = 0;
+ return;
+ } else if (TYPE(rv) == T_OBJECT) {
+ // A Qt::Integer has been passed as an integer value
+ VALUE temp = rb_funcall(qt_internal_module, rb_intern("get_qinteger"), 1, rv);
+ *i = NUM2INT(temp);
+ m->item().s_voidp = i;
+ m->next();
+ rb_funcall(qt_internal_module, rb_intern("set_qinteger"), 2, rv, INT2NUM(*i));
+ rv = temp;
+ } else {
+ *i = NUM2UINT(rv);
+ m->item().s_voidp = i;
+ m->next();
+ }
+
+ if(m->cleanup() && m->type().isConst()) {
+ delete i;
+ } else {
+ m->item().s_voidp = new int((int)NUM2UINT(rv));
+ }
+}
+
+template <>
+void marshall_to_ruby<unsigned int *>(Marshall *m)
+{
+ unsigned int *ip = (unsigned int*) m->item().s_voidp;
+ VALUE rv = *(m->var());
+ if (ip == 0) {
+ rv = Qnil;
+ return;
+ }
+
+ *(m->var()) = UINT2NUM(*ip);
+ m->next();
+ if(!m->type().isConst())
+ *ip = NUM2UINT(*(m->var()));
+}
+
+template <>
void marshall_from_ruby<bool *>(Marshall *m)
{
VALUE rv = *(m->var());
More information about the Kde-bindings
mailing list