[Kde-bindings] KDE/kdebindings/ruby

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon May 19 09:39:14 UTC 2008


SVN commit 809704 by rdale:

* Move the Soprano bindings to their own mini-project which now covers the complete
  api

CCMAIL: kde-bindings at kde.org

 D             korundum/activerdf-soprano (directory)  
 M  +6 -108    korundum/src/Korundum.cpp  
 M  +4 -4      korundum/src/krubypluginfactory.cpp  
 M  +1 -1      korundum/src/lib/KDE/CMakeLists.txt  
 D             korundum/src/lib/KDE/soprano.rb  
 A             soprano (directory)  
 A             soprano/CMakeLists.txt  
 A             soprano/activerdf-soprano (directory)  
 A             soprano/activerdf-soprano/CHANGELOG  
 A             soprano/activerdf-soprano/LICENSE  
 A             soprano/activerdf-soprano/README  
 A             soprano/activerdf-soprano/Rakefile  
 A             soprano/activerdf-soprano/VERSION  
 A             soprano/activerdf-soprano/lib (directory)  
 A             soprano/activerdf-soprano/lib/activerdf_soprano (directory)  
 A             soprano/activerdf-soprano/lib/activerdf_soprano/init.rb  
 A             soprano/activerdf-soprano/lib/activerdf_soprano/literal.rb  
 A             soprano/activerdf-soprano/lib/activerdf_soprano/soprano.rb  
 A             soprano/activerdf-soprano/rakehelp.rb  
 A             soprano/activerdf-soprano/test (directory)  
 A             soprano/activerdf-soprano/test/test_person_data.nt  
 A             soprano/activerdf-soprano/test/test_soprano_adapter.rb  
 A             soprano/soprano.cpp   [License: UNKNOWN]
 A             soprano/soprano.rb  
 A             soprano/sopranohandlers.cpp   [License: GPL (v2+)]


--- trunk/KDE/kdebindings/ruby/korundum/src/Korundum.cpp #809703:809704
@@ -28,10 +28,6 @@
 #include <QtCore/qtextstream.h>
 #include <QtDBus/qdbusmetatype.h>
 
-#include <soprano/node.h>
-#include <soprano/statement.h>
-#include <soprano/bindingset.h>
-
 #include <kdeversion.h>
 #include <kapplication.h>
 #include <kconfigskeleton.h>
@@ -62,94 +58,6 @@
     return classList;
 }
 
-/* 
- * These QDBusArgument operators are copied from kdesupport/soprano/server/dbus/dbusoperators.cpp
- */
-Q_DECLARE_METATYPE(Soprano::Statement)
-Q_DECLARE_METATYPE(Soprano::Node)
-Q_DECLARE_METATYPE(Soprano::BindingSet)
-
-QDBusArgument& operator<<( QDBusArgument& arg, const Soprano::Node& node )
-{
-    arg.beginStructure();
-    arg << ( int )node.type() << node.toString() << node.language() << node.dataType().toString();
-    arg.endStructure();
-    return arg;
-}
-
-const QDBusArgument& operator>>( const QDBusArgument& arg, Soprano::Node& node )
-{
-    arg.beginStructure();
-    int type;
-    QString value, language, dataTypeUri;
-    arg >> type >> value >> language >> dataTypeUri;
-    if ( type == Soprano::Node::LiteralNode ) {
-        node = Soprano::Node( Soprano::LiteralValue::fromString( value, dataTypeUri ), language );
-    }
-    else if ( type == Soprano::Node::ResourceNode ) {
-        node = Soprano::Node( QUrl( value ) );
-    }
-    else if ( type == Soprano::Node::BlankNode ) {
-        node = Soprano::Node( value );
-    }
-    else {
-        node = Soprano::Node();
-    }
-    arg.endStructure();
-    return arg;
-}
-
-QDBusArgument& operator<<( QDBusArgument& arg, const Soprano::Statement& statement )
-{
-    arg.beginStructure();
-    arg << statement.subject() << statement.predicate() << statement.object() << statement.context();
-    arg.endStructure();
-    return arg;
-}
-
-const QDBusArgument& operator>>( const QDBusArgument& arg, Soprano::Statement& statement )
-{
-    arg.beginStructure();
-    Soprano::Node subject, predicate, object, context;
-    arg >> subject >> predicate >> object >> context;
-    statement = Soprano::Statement( subject, predicate, object, context );
-    arg.endStructure();
-    return arg;
-}
-
-QDBusArgument& operator<<( QDBusArgument& arg, const Soprano::BindingSet& set )
-{
-    arg.beginStructure();
-    arg.beginMap( QVariant::String, qMetaTypeId<Soprano::Node>() );
-    QStringList names = set.bindingNames();
-    for ( int i = 0; i < names.count(); ++i ) {
-        arg.beginMapEntry();
-        arg << names[i] << set[ names[i] ];
-        arg.endMapEntry();
-    }
-    arg.endMap();
-    arg.endStructure();
-    return arg;
-}
-
-const QDBusArgument& operator>>( const QDBusArgument& arg, Soprano::BindingSet& set )
-{
-    arg.beginStructure();
-    arg.beginMap();
-    while ( !arg.atEnd() ) {
-        QString name;
-        Soprano::Node val;
-        arg.beginMapEntry();
-        arg >> name >> val;
-        arg.endMapEntry();
-        set.insert( name, val );
-    }
-
-    arg.endMap();
-    arg.endStructure();
-    return arg;
-}
-
 extern "C" {
 VALUE kconfigskeleton_class;
 }
@@ -201,11 +109,6 @@
 new_kconfigskeleton_itemlonglong(int argc, VALUE * argv, VALUE self)
 {
 }
-
-static VALUE
-new_kconfigskeleton_itempathlist(int argc, VALUE * argv, VALUE self)
-{
-}
 */
 
 template <class SkeletonItem, const char *SkeletonItemSTR >
@@ -374,6 +277,8 @@
 	VALUE result = Data_Wrap_Struct(klass, smokeruby_mark, smokeruby_free, o);
 	mapObject(result, result);
 	rb_throw("newqt", result);
+	/*NOTREACHED*/
+	return self;
 }
 
 #define DEF_SKELETON_PRIMITIVE_ITEM_CONSTRUCTOR(Method, SkeletonItem, Item) namespace { char Method##STR[] = #SkeletonItem; }  \
@@ -415,9 +320,10 @@
 		return rb_call_super(argc, argv);
 	}
 
+	Smoke::ModuleIndex mi = qt_Smoke->findClass(SkeletonItemSTR);
 	smokeruby_object  * o = alloc_smokeruby_object(	true, 
-													argv2->smoke, 
-													argv2->smoke->idClass(SkeletonItemSTR).index, 
+													mi.smoke, 
+													mi.index, 
 													skeletonItem );
 
 	VALUE klass = rb_funcall(self, rb_intern("class"), 0);
@@ -531,7 +437,6 @@
 VALUE kwallet_module;
 VALUE safesite_module;
 VALUE sonnet_module;
-VALUE soprano_module;
 VALUE nepomuk_module;
 
 static VALUE kde_module_method_missing(int argc, VALUE * argv, VALUE klass)
@@ -594,10 +499,6 @@
 	rb_define_singleton_method(sonnet_module, "method_missing", (VALUE (*) (...)) kde_module_method_missing, -1);
 	rb_define_singleton_method(sonnet_module, "const_missing", (VALUE (*) (...)) kde_module_method_missing, -1);
 
-	soprano_module = rb_define_module("Soprano");
-	rb_define_singleton_method(soprano_module, "method_missing", (VALUE (*) (...)) kde_module_method_missing, -1);
-	rb_define_singleton_method(soprano_module, "const_missing", (VALUE (*) (...)) kde_module_method_missing, -1);
-
 	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);
@@ -606,7 +507,7 @@
 Q_DECL_EXPORT void
 Init_korundum4()
 {
-    rb_require("Qt");    // need to initialize the core runtime first
+    rb_require("Qt4");    // need to initialize the core runtime first
     init_kde_Smoke();
 
     kde_Smoke->binding = new QtRubySmokeBinding(kde_Smoke);
@@ -623,9 +524,6 @@
 
     rb_define_singleton_method(kde_internal_module, "getClassList", (VALUE (*) (...)) getClassList, 0);
 
-	(void) qDBusRegisterMetaType<Soprano::Statement>();
-	(void) qDBusRegisterMetaType<Soprano::Node>();
-	(void) qDBusRegisterMetaType<Soprano::BindingSet>();
 	(void) qRegisterMetaType<KUrl>();
 
     rb_require("KDE/korundum4.rb");
--- trunk/KDE/kdebindings/ruby/korundum/src/krubypluginfactory.cpp #809703:809704
@@ -86,7 +86,7 @@
         virtual QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword);
 
     private:
-        static QByteArray toCamelCase(QByteArray name);
+        static QByteArray camelize(QByteArray name);
 };
 K_EXPORT_PLUGIN(KRubyPluginFactory)
 
@@ -95,7 +95,7 @@
 {
 }
 
-QByteArray KRubyPluginFactory::toCamelCase(QByteArray name)
+QByteArray KRubyPluginFactory::camelize(QByteArray name)
 {
     // Convert foo_bar_baz to FooBarBaz
     QByteArray camelCaseName = name.left(1).toUpper();
@@ -143,8 +143,8 @@
     }
 
     // A path of my_app/foo_bar.rb is turned into module/class 'MyApp::FooBar'
-    const QByteArray moduleName = KRubyPluginFactory::toCamelCase(QFile::encodeName(program.dir().dirName()));
-    const QByteArray className = KRubyPluginFactory::toCamelCase(program.baseName().toLatin1());
+    const QByteArray moduleName = KRubyPluginFactory::camelize(QFile::encodeName(program.dir().dirName()));
+    const QByteArray className = KRubyPluginFactory::camelize(program.baseName().toLatin1());
 
     VALUE plugin_module = rb_const_get(rb_cObject, rb_intern(moduleName));
     if (plugin_module == Qnil) {
--- trunk/KDE/kdebindings/ruby/korundum/src/lib/KDE/CMakeLists.txt #809703:809704
@@ -1 +1 @@
-install( FILES  korundum4.rb soprano.rb DESTINATION ${CUSTOM_RUBY_SITE_LIB_DIR}/KDE )
+install( FILES  korundum4.rb DESTINATION ${CUSTOM_RUBY_SITE_LIB_DIR}/KDE )



More information about the Kde-bindings mailing list