[Kde-bindings] playground/bindings/kimono
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Thu Oct 19 11:37:09 UTC 2006
SVN commit 597077 by rdale:
* Removed Qt3 Qyoto sources
* Moved Qyoto.cs to the top directory, so that only autogenerated
classes are in the qyoto directory.
* Added some non-working list marshalling code for QStringLists and
QList<QVector> so that they can be used for getting QDBus to work
* Removed assignment to the qApp global variable in the QCoreApplication
constructor as C# doesn't support downcasting.
CCMAIL: kde-bindings at kde.org
M +10 -0 ChangeLog
M +175 -0 handlers.cpp
D qt3handlers.cpp
D qt3qyoto (directory)
M +1 -1 qyoto/QCoreApplication.cs
--- trunk/playground/bindings/kimono/ChangeLog #597076:597077
@@ -1,3 +1,13 @@
+2006-10-19 Richard Dale <rdale at foton.es>
+
+ * Removed Qt3 Qyoto sources
+ * Moved Qyoto.cs to the top directory, so that only autogenerated
+ classes are in the qyoto directory.
+ * Added some non-working list marshalling code for QStringLists and
+ QList<QVector> so that they can be used for getting QDBus to work
+ * Removed assignment to the qApp global variable in the QCoreApplication
+ constructor as C# doesn't support downcasting.
+
2006-10-18 Richard Dale <rdale at foton.es>
* Enum return types were failing with an invalid cast error.
--- trunk/playground/bindings/kimono/handlers.cpp #597076:597077
@@ -768,7 +768,176 @@
}
}
+void marshall_QStringList(Marshall *m) {
+ switch(m->action()) {
+ case Marshall::FromObject:
+ {
+// VALUE list = *(m->var());
+// if (TYPE(list) != T_ARRAY) {
+// m->item().s_voidp = 0;
+// break;
+// }
+// int count = RARRAY(list)->len;
+ int count = 0;
+ QStringList *stringlist = new QStringList;
+
+ for (long i = 0; i < count; i++) {
+// VALUE item = rb_ary_entry(list, i);
+// if(TYPE(item) != T_STRING) {
+ stringlist->append(QString());
+// continue;
+// }
+// stringlist->append(*(qstringFromRString(item)));
+ }
+
+ m->item().s_voidp = stringlist;
+ m->next();
+
+ if (stringlist != 0 && !m->type().isConst()) {
+// rb_ary_clear(list);
+ for (QStringList::Iterator it = stringlist->begin(); it != stringlist->end(); ++it) {
+// rb_ary_push(list, rstringFromQString(&(*it)));
+ }
+ }
+
+ if (m->cleanup()) {
+ delete stringlist;
+ }
+
+ break;
+ }
+
+ case Marshall::ToObject:
+ {
+ QStringList *stringlist = static_cast<QStringList *>(m->item().s_voidp);
+ if (!stringlist) {
+// *(m->var()) = Qnil;
+ break;
+ }
+
+// VALUE av = rb_ary_new();
+ for (QStringList::Iterator it = stringlist->begin(); it != stringlist->end(); ++it) {
+// VALUE rv = rstringFromQString(&(*it));
+// rb_ary_push(av, rv);
+ }
+
+// *(m->var()) = av;
+
+ if (m->cleanup()) {
+ delete stringlist;
+ }
+
+ }
+ break;
+ default:
+ m->unsupported();
+ break;
+ }
+}
+
+template <class Item, class ItemList, const char *ItemSTR >
+void marshall_ValueListItem(Marshall *m) {
+ switch(m->action()) {
+ case Marshall::FromObject:
+ {
+// VALUE list = *(m->var());
+// if (TYPE(list) != T_ARRAY) {
+ m->item().s_voidp = 0;
+// break;
+// }
+// int count = RARRAY(list)->len;
+ int count = 0;
+ ItemList *cpplist = new ItemList;
+ long i;
+ for(i = 0; i < count; i++) {
+// VALUE item = rb_ary_entry(list, i);
+ // TODO do type checking!
+ smokeqyoto_object *o = value_obj_info(0);
+ if(!o || !o->ptr)
+ continue;
+
+ void *ptr = o->ptr;
+ ptr = o->smoke->cast(
+ ptr, // pointer
+ o->classId, // from
+ o->smoke->idClass(ItemSTR) // to
+ );
+ cpplist->append(*(Item*)ptr);
+ }
+
+ m->item().s_voidp = cpplist;
+ m->next();
+
+ if (!m->type().isConst()) {
+// rb_ary_clear(list);
+ for(int i=0; i < cpplist->size(); ++i) {
+// VALUE obj = getPointerObject((void*)&(cpplist->at(i)));
+// rb_ary_push(list, obj);
+ }
+ }
+
+ if (m->cleanup()) {
+ delete cpplist;
+ }
+ }
+ break;
+
+ case Marshall::ToObject:
+ {
+ ItemList *valuelist = (ItemList*)m->item().s_voidp;
+ if (valuelist == 0) {
+// *(m->var()) = Qnil;
+ break;
+ }
+
+// VALUE av = rb_ary_new();
+
+ int ix = m->smoke()->idClass(ItemSTR);
+ const char * className = m->smoke()->binding->className(ix);
+
+ for (int i=0; i < valuelist->size() ; ++i) {
+ void *p = (void *) &(valuelist->at(i));
+
+ if (m->item().s_voidp == 0) {
+// *(m->var()) = Qnil;
+ break;
+ }
+
+// VALUE obj = getPointerObject(p);
+// if(obj == Qnil) {
+ smokeqyoto_object * o = (smokeqyoto_object *) malloc(sizeof(smokeqyoto_object));
+ o->smoke = m->smoke();
+ o->classId = o->smoke->idClass(ItemSTR);
+ o->ptr = p;
+ o->allocated = false;
+// obj = set_obj_info(className, o);
+// }
+
+// rb_ary_push(av, obj);
+ }
+
+// *(m->var()) = av;
+ m->next();
+
+ if (m->cleanup()) {
+ delete valuelist;
+ }
+
+ }
+ break;
+
+ default:
+ m->unsupported();
+ break;
+ }
+}
+
+#define DEF_VALUELIST_MARSHALLER(ListIdent,ItemList,Item) namespace { char ListIdent##STR[] = #Item; }; \
+ Marshall::HandlerFn marshall_##ListIdent = marshall_ValueListItem<Item,ItemList,ListIdent##STR>;
+
+DEF_VALUELIST_MARSHALLER( QVariantList, QList<QVariant>, QVariant )
+
TypeHandler Qt_handlers[] = {
{ "QString", marshall_QString },
{ "QString&", marshall_QString },
@@ -777,7 +946,13 @@
{ "int*", marshall_intR },
{ "char*", marshall_charP },
{ "char**", marshall_charP_array },
+ { "QStringList", marshall_QStringList },
+ { "QStringList&", marshall_QStringList },
+ { "QStringList*", marshall_QStringList },
// { "void**", marshall_voidP_array },
+ { "QList<QVariant>", marshall_QVariantList },
+ { "QList<QVariant>&", marshall_QVariantList },
+ { "QVariantList&", marshall_QVariantList },
{ 0, 0 }
};
--- trunk/playground/bindings/kimono/qyoto/QCoreApplication.cs #597076:597077
@@ -252,7 +252,7 @@
public QCoreApplication(string[] argv) : this((Type) null) {
Qyoto.Init_qyoto();
CreateProxy();
- Qt.qApp = (QApplication) this;
+// Qt.qApp = (QApplication) this;
string[] args = new string[argv.Length + 1];
args[0] = System.Reflection.Assembly.GetExecutingAssembly().Location;
More information about the Kde-bindings
mailing list