[Kde-bindings] KDE/kdebindings/php/phpqt/src

Thomas Moenicke tm at php-qt.org
Sun Nov 2 20:57:43 UTC 2008


SVN commit 879268 by moenicke:

* added scope-zval for having access to the object in a parent:: call

CCMAIL: kde-bindings at kde.org



 M  +12 -2     MethodCall.cpp  
 M  +9 -3      context.cpp  
 M  +1 -0      context.h  
 M  +1 -4      php_qt.cpp  
 M  +3 -2      zend_handlers.cpp  


--- trunk/KDE/kdebindings/php/phpqt/src/MethodCall.cpp #879267:879268
@@ -6,7 +6,8 @@
 #include "phpqt_internals.h"
 #include "marshall_types.h"
 #include "context.h"
-#include <QDebug>
+#include "pDebug.h"
+
 MethodCall::MethodCall(Smoke *smoke, const Smoke::Index method, zval* target, zval **sp, zval *&retval) :
     MethodCallBase(smoke,method,sp),
     _target(target),
@@ -23,6 +24,11 @@
         }
     }
 
+    if( !(MethodCallBase::method().flags & Smoke::mf_static) && !(MethodCallBase::method().flags & Smoke::mf_ctor) && _o == 0 ){
+	_target = Context::activeScope();
+        _o = PHPQt::getSmokePHPObjectFromZval(_target);
+    }
+
     _args = _smoke->argumentList + _smoke->methods[_method].args;
     _items = _smoke->methods[_method].numArgs;
     // TODO memory test
@@ -56,7 +62,7 @@
 	if(_called) return;
 	_called = true;
 
-	QByteArray className(_smoke->className(method().classId));
+	const QByteArray className(_smoke->className(method().classId));
 
 	if (! className.endsWith(_smoke->methodNames[method().name])
 		&& Z_TYPE_P(_target) == IS_NULL
@@ -73,12 +79,16 @@
 	const Smoke::ClassFn fn = _smoke->classes[method().classId].classFn;
 
 	void *ptr = 0;
+
 	if (_o != 0) {
 		const Smoke::Class &cl = _smoke->classes[method().classId];
 
 		ptr = _o->smoke()->cast(	(void *) _o->ptr(),
 									_o->classId(),
 									_o->smoke()->idClass(cl.className, true).index );
+	} else {
+	    if( !(method().flags & Smoke::mf_static) && !(method().flags & Smoke::mf_ctor) )
+		pError( PHPQt::Method ) << "cannot call non-static " << className << "::" << Context::methodName()->constData() << " without an object.";
 	}
 
 	_items = -1;
--- trunk/KDE/kdebindings/php/phpqt/src/context.cpp #879267:879268
@@ -38,7 +38,7 @@
 
     QStack< QByteArray* > m_methodNameStack;
     QStack< zend_class_entry* > classEntryStack;
-    QStack< zval* > zvalStack;
+    zval* m_scope;
     zend_class_entry* m_activeCe;
     zval* m_activeScope;
     bool m_parentCall;
@@ -83,16 +83,22 @@
 zval*
 Context::activeScope()
 {
-    return m_Context->d->m_activeScope;
+    return m_Context->d->m_scope;
 }
 
 void
 Context::setActiveScope(zval* zval_ptr)
 {
-    m_Context->d->m_activeScope = zval_ptr;
+    m_Context->d->m_scope = zval_ptr;
 }
 
 void
+Context::removeActiveScope()
+{
+    m_Context->d->m_scope = 0;
+}
+
+void
 Context::setParentCall(bool pc)
 {
     m_Context->d->m_parentCall = pc;
--- trunk/KDE/kdebindings/php/phpqt/src/context.h #879267:879268
@@ -40,6 +40,7 @@
 
     static void setActiveCe(zend_class_entry* activeCePtr);
     static void setActiveScope(zval* zval_ptr);
+    static void removeActiveScope();
     static void setParentCall(bool pc);
     static void setMethodName(const char* name);
 
--- trunk/KDE/kdebindings/php/phpqt/src/php_qt.cpp #879267:879268
@@ -48,9 +48,6 @@
 // context, threadsafe
 QStack<QByteArray*> methodNameStack_;
 
-zval* activeScope_;
-bool parentCall_;
-
 // cached, readonly
 Smoke::Index qbool;
 Smoke::Index qstring;
@@ -348,7 +345,7 @@
 ZEND_METHOD(php_qt_generic_class, staticProxyMethod)
 {
     Context::setCallType( Context::StaticMethodCall );
-    
+
     ALLOC_INIT_ZVAL( this_ptr );
     object_init_ex( this_ptr, Context::activeCe() ); 
     Context::removeActiveCe();
--- trunk/KDE/kdebindings/php/phpqt/src/zend_handlers.cpp #879267:879268
@@ -54,7 +54,7 @@
 union _zend_function*
 ZendHandlers::proxyHandler(zval **obj_ptr, char* methodName, int methodName_len TSRMLS_DC)
 {
-	// check if defined by the user
+    // check if defined by the user
     union _zend_function *fbc;
     QByteArray lcMethodName( methodName );
     zend_object *zobj = zend_objects_get_address(*obj_ptr TSRMLS_CC);
@@ -71,10 +71,11 @@
 
     // a try for non-Qt objects
     fbc = zend_orig_handler.get_method( obj_ptr, methodName, methodName_len );
+    Context::setActiveScope( *obj_ptr ); // it might go through staticProxy for parent:: calls 
     if(!fbc) // maybe a Qt object
     {
     	Context::setMethodName( methodName );
-    	// call proxy
+   	// call proxy
     	fbc = zend_orig_handler.get_method(obj_ptr, "proxyMethod", 11);
     }
 



More information about the Kde-bindings mailing list