[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kjsembed
Subject:    [kjsembed] eval returnvalue in qobject_binding.cpp#callAsFunction
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2006-10-05 23:35:13
Message-ID: 200610060135.18785.mail () dipe ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


hi * :)

the attached patch tries to add support for handling of slot returnvalues at 
the QObject binding.

* Unittest I used to test the returnvalues (bytearray does not work, how to 
define a QStringList in javascript?); 
http://websvn.kde.org/trunk/koffice/libs/kross/test/unittest.js?rev=586618&view=markup

* I didn't regressiontest it so much.

* It may crash or do some other dirty things if e.g. a QVariant::UserType got 
passed.

* Any feedback is welcome :)

-- 
Sebastian Sauer aka dipesh[sebsauer]
http://www.dipe.org/public_key.asc
Fingerprint: 8F1E 219B 16E6 4EC7 29CC F408 E193 65E2 9134 2221
Coder in http://www.koffice.org && http://www.kmldonkey.org

["kjsembed.patch" (text/x-diff)]

Index: qobject_binding.cpp
===================================================================
--- qobject_binding.cpp	(Revision 592034)
+++ qobject_binding.cpp	(Arbeitskopie)
@@ -31,6 +31,7 @@
 #include "jseventmapper.h"
 #include "pointer.h"
 #include "qobject_binding.h"
+#include "variant_binding.h"
 
 #include <kjs/function_object.h>
 #include <kjs/property_slot.h>
@@ -376,7 +377,6 @@
     PointerBase *qtArgs[10];
     void *param[11];
 
-    QGenericArgument returnArgument;
     QObject *object = imp->object<QObject>();
     int count = object->metaObject()->methodCount();
     QMetaMethod metaMember;
@@ -398,6 +398,9 @@
 //    int kjsArgCount = args.size();
 //    int qArgCount = types.size();
 
+    QVariant::Type returnTypeId = QVariant::nameToType( metaMember.typeName() );
+    QVariant returnValue( returnTypeId );
+    QGenericReturnArgument returnArgument(metaMember.typeName(), &returnValue);
     param[0] = returnArgument.data();
     for( int idx = 0; idx < 10; ++idx)
     {
@@ -409,7 +412,6 @@
     success = object->qt_metacall(QMetaObject::InvokeMetaMethod, offset, param) < 0;
     //qDebug("after param ptr %0x", *(void**)param[1]);
 
-
     for( int idx = 0; idx < 10; ++idx)
     {
         delete qtArgs[idx];
@@ -420,7 +422,8 @@
         KJS::throwError(exec, KJS::GeneralError, i18n("Call to '%1' failed.",  \
                m_memberName.constData()));
         // KJSEmbed::throwError(exec, i18n("Call to '%1' \
failed.").arg(m_memberName.constData()));  }
-    return KJS::Boolean(success);
+
+    return KJSEmbed::convertToValue(exec, returnValue);
 }
 
 SlotBinding::SlotBinding(KJS::ExecState *exec, const QMetaMethod &member )


[Attachment #8 (application/pgp-signature)]

_______________________________________________
kjsembed mailing list
kjsembed@kde.org
https://mail.kde.org/mailman/listinfo/kjsembed


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic