[Kde-bindings] KDE/kdebindings/csharp/plasma
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Jul 8 08:40:01 UTC 2008
SVN commit 829352 by rdale:
* Added a marshaller for the Plasma::DataEngine::Data type so that
DateUpdated() slots should work
* Fixed overriden virtual methods in the Tiger applet so they work by addding
the 'override' keyword to the declarations.
CCMAIL: kde-bindings at kde.org
M +6 -0 ChangeLog
M +0 -2 src/PlasmaScriptengineKimono_Applet.cs
M +43 -66 src/plasmahandlers.cpp
--- trunk/KDE/kdebindings/csharp/plasma/ChangeLog #829351:829352
@@ -1,3 +1,9 @@
+2008-07-08 Richard Dale <richard.j.dale at gmail.com>
+* Added a marshaller for the Plasma::DataEngine::Data type so that
+ DateUpdated() slots should work
+* Fixed overriden virtual methods in the Tiger applet so they work by addding
+ the 'override' keyword to the declarations.
+
2008-07-07 Richard Dale <richard.j.dale at gmail.com>
* Added a tiger example C# applet. It wasn't possible to build an executable
called 'main' as mono gave an error about it not having an extension.
--- trunk/KDE/kdebindings/csharp/plasma/src/PlasmaScriptengineKimono_Applet.cs #829351:829352
@@ -41,11 +41,9 @@
Applet().Resize(200, 200);
QFileInfo program = new QFileInfo(MainScript());
- Console.WriteLine("Loading main script {0}", program.AbsoluteFilePath());
appletAssembly = Assembly.LoadFile(program.AbsoluteFilePath());
string typeName = Camelize(Package().Metadata().PluginName()) + "."; // namespace
typeName += Camelize(program.CompleteBaseName());
- Console.WriteLine("GetType() for {0}", typeName);
appletType = appletAssembly.GetType(typeName);
applet = (PlasmaScripting.Applet) Activator.CreateInstance(appletType, new object[] { this });
--- trunk/KDE/kdebindings/csharp/plasma/src/plasmahandlers.cpp #829351:829352
@@ -60,80 +60,57 @@
break;
}
}
+*/
void marshall_QHashQStringQVariant(Marshall *m) {
switch(m->action()) {
- case Marshall::FromVALUE:
- {
- VALUE hash = *(m->var());
- if (TYPE(hash) != T_HASH) {
- m->item().s_voidp = 0;
+ case Marshall::FromObject:
+ {
+ if (m->var().s_class == 0) {
+ m->item().s_class = 0;
+ return;
+ }
+ QHash<QString, QVariant>* map = (QHash<QString, QVariant>*) (*DictionaryToQHash)(m->var().s_voidp, 2);
+ m->item().s_voidp = (void*) map;
+ m->next();
+
+ if (m->cleanup()) {
+ delete map;
+ }
+ (*FreeGCHandle)(m->var().s_voidp);
break;
- }
-
- QHash<QString,QVariant> * map = new QHash<QString,QVariant>;
-
- // Convert the ruby hash to an array of key/value arrays
- VALUE temp = rb_funcall(hash, rb_intern("to_a"), 0);
+ }
- for (long i = 0; i < RARRAY(temp)->len; i++) {
- VALUE key = rb_ary_entry(rb_ary_entry(temp, i), 0);
- VALUE value = rb_ary_entry(rb_ary_entry(temp, i), 1);
+ case Marshall::ToObject:
+ {
+ QHash<QString, QVariant>* map = (QHash<QString, QVariant>*) m->item().s_voidp;
+ void* dict = (*ConstructDictionary)("System.String", "Qyoto.QVariant");
- smokeruby_object *o = value_obj_info(value);
- if (o == 0 || o->ptr == 0) {
- continue;
+ Smoke::ModuleIndex id = m->smoke()->findClass("QVariant");
+
+ for (QHash<QString, QVariant>::iterator i = map->begin(); i != map->end(); ++i) {
+ void* v = (void*) &(i.value());
+ smokeqyoto_object * vo = alloc_smokeqyoto_object(false, id.smoke, id.index, v);
+ void* value = (*CreateInstance)("Qyoto.QVariant", vo);
+ void* string = (void*) StringFromQString((void*) &(i.key()));
+ (*AddObjectObjectToDictionary)( dict,
+ string,
+ value);
+ (*FreeGCHandle)(string);
+ (*FreeGCHandle)(value);
}
- (*map)[QString(StringValuePtr(key))] = (QVariant)*(QVariant*)o->ptr;
- }
-
- m->item().s_voidp = map;
- m->next();
-
- if(m->cleanup())
- delete map;
- }
- break;
- case Marshall::ToVALUE:
- {
- QHash<QString,QVariant> *map = (QHash<QString,QVariant>*)m->item().s_voidp;
- if (!map) {
- *(m->var()) = Qnil;
+ m->var().s_voidp = dict;
+ m->next();
+
break;
}
-
- VALUE hv = rb_hash_new();
-
- QHash<QString,QVariant>::Iterator it;
- for (it = map->begin(); it != map->end(); ++it) {
- void *p = new QVariant(it.value());
- VALUE obj = getPointerObject(p);
-
- if (obj == Qnil) {
- smokeruby_object * o = alloc_smokeruby_object( true,
- m->smoke(),
- m->smoke()->idClass("QVariant").index,
- p );
- obj = set_obj_info("Qt::Variant", o);
- }
-
- rb_hash_aset(hv, rb_str_new2(((QString*)&(it.key()))->toLatin1()), obj);
- }
-
- *(m->var()) = hv;
- m->next();
-
-// if(m->cleanup())
-// delete map;
- }
- break;
- default:
- m->unsupported();
- break;
+
+ default:
+ m->unsupported();
+ break;
}
}
-*/
DEF_LIST_MARSHALLER( PlasmaContainmentList, QList<Plasma::Containment*>, Plasma::Containment )
DEF_LIST_MARSHALLER( PlasmaAppletList, QList<Plasma::Applet*>, Plasma::Applet )
@@ -144,10 +121,10 @@
TypeHandler Plasma_handlers[] = {
// { "Plasma::PackageStructure::Ptr", marshall_PackageStructurePtr },
-// { "QHash<QString,QVariant>", marshall_QHashQStringQVariant },
-// { "QHash<QString,QVariant>&", marshall_QHashQStringQVariant },
-// { "Plasma::DataEngine::Data", marshall_QHashQStringQVariant },
-// { "Plasma::DataEngine::Data&", marshall_QHashQStringQVariant },
+ { "QHash<QString,QVariant>", marshall_QHashQStringQVariant },
+ { "QHash<QString,QVariant>&", marshall_QHashQStringQVariant },
+ { "Plasma::DataEngine::Data", marshall_QHashQStringQVariant },
+ { "Plasma::DataEngine::Data&", marshall_QHashQStringQVariant },
// { "Plasma::DataEngine::SourceDict", marshall_QHashQStringDataContainer },
// { "Plasma::DataEngine::Dict", marshall_QHashQStringDataEngine },
{ "QList<Plasma::Containment*>", marshall_PlasmaContainmentList },
More information about the Kde-bindings
mailing list