[Kde-bindings] KDE/kdebindings/php/phpqt
Thomas Moenicke
tm at php-qt.org
Sat Oct 25 14:18:11 UTC 2008
SVN commit 875761 by moenicke:
* fix this_ptr in the proxy method, for static method calls
* added C++ unittests for callbacks into the engine, those can be invoked using the callbackTests.php script. For now the virtual method call QWidget::paintEvent(QPaintEvent* event) is covered
CCMAIL: kde-bindings at kde.org
M +8 -0 src/CMakeLists.txt
M +23 -0 src/functions.cpp
M +10 -4 src/php_qt.cpp
A src/unittests.cpp [License: UNKNOWN]
A src/unittests.h [License: UNKNOWN]
M +1 -1 src/zend_extension.h
A tests/callbackTests.php
--- trunk/KDE/kdebindings/php/phpqt/src/CMakeLists.txt #875760:875761
@@ -36,6 +36,7 @@
)
set(phpqt_LIB_SRCS
+ unittests.cpp
functions.cpp
php_qt.cpp
zend_handlers.cpp
@@ -55,10 +56,17 @@
VirtualMethodReturnValue.cpp
)
+set(phpqt_MOC_HEADER
+ unittests.h
+)
+
+qt_wrap_cpp( php_qt phpqt_LIB_SRCS ${phpqt_MOC_HEADER} )
+
add_library(php_qt MODULE ${phpqt_LIB_SRCS})
target_link_libraries(php_qt
${QT_QTCORE_LIBRARY}
+ ${QT_QTTEST_LIBRARY}
smokeqt
)
--- trunk/KDE/kdebindings/php/phpqt/src/functions.cpp #875760:875761
@@ -35,6 +35,9 @@
#include "php_qt.h"
#include "zend_extension.h"
+#include "unittests.h"
+#include <QTest>
+
extern Smoke *qt_Smoke;
extern Smoke::Index qstring;
extern zend_class_entry* qstring_ce;
@@ -817,3 +820,23 @@
return;
}
+
+
+extern "C" PHP_FUNCTION( __phpqt_unittest_invoke )
+{
+
+ Q_UNUSED(return_value_ptr);
+ Q_UNUSED(this_ptr);
+ Q_UNUSED(return_value_used);
+
+ const int argc = ZEND_NUM_ARGS();
+ zval ***args = static_cast<zval***>( safe_emalloc(argc, sizeof(zval), 0) );
+
+ if(zend_get_parameters_array_ex(argc, args) == FAILURE){
+ efree(args);
+ WRONG_PARAM_COUNT;
+ }
+
+ TestPHPQt test( PQ::binding(), *args[0] );
+ QTest::qExec( &test );
+}
--- trunk/KDE/kdebindings/php/phpqt/src/php_qt.cpp #875760:875761
@@ -104,6 +104,7 @@
PHP_FE(tr, NULL)
PHP_FE(check_qobject, NULL)
PHP_FE(Q_UNUSED, NULL)
+ PHP_FE(__phpqt_unittest_invoke, NULL)
{NULL, NULL, NULL} /* Must be the last line in php_qt_functions[] */
};
@@ -197,7 +198,7 @@
Smoke::StackItem stack[1];
(*fn)( m.method, o->mPtr(), stack );
}*/
- if(!PHPQt::unmapSmokePHPObject(o))
+ if ( !PHPQt::unmapSmokePHPObject(o) )
pError() << "tried to unmap unregistered smoke object";
efree( (void*) o->zval_ptr() );
@@ -282,7 +283,13 @@
smokephp_prepareMethodName(args, argc);
const Smoke::Index method = smokephp_getMethod(ce->name, Context::methodName()->constData(), argc, args);
-
+ // for static methods that are called on an object
+ if( PQ::smoke()->methods[ method ].flags & Smoke::mf_static )
+ {
+ pNotice() << "called static method on an object" << Context::methodName();
+ this_ptr = 0;
+ Context::setActiveCe( ce );
+ }
if(method <= 0) { // its a user signal
if( Context::methodName()->constData() ) {
@@ -290,7 +297,7 @@
// is it a signal?
if(getThis()){
smokephp_object* o = PHPQt::getSmokePHPObjectFromZval(getThis());
- if(o->meta() != 0){
+ if( o && o->meta() != 0){
Context::setCallType( Context::SignalCall );
const QMetaObject* mo = o->meta();
QByteArray signalName( Context::methodName()->constData() );
@@ -357,7 +364,6 @@
zim_php_qt_generic_class_proxyMethod(ht, return_value, return_value_ptr, this_ptr, return_value_used);
// we assume the active ce has been used
Context::removeActiveCe();
- Context::removeStaticZVal();
}
/*!
--- trunk/KDE/kdebindings/php/phpqt/src/zend_extension.h #875760:875761
@@ -72,7 +72,7 @@
PHP_FUNCTION(tr);
PHP_FUNCTION(check_qobject);
PHP_FUNCTION(Q_UNUSED);
-
+PHP_FUNCTION(__phpqt_unittest_invoke);
} // extern "C"
More information about the Kde-bindings
mailing list