chregu Tue Apr 20 05:24:24 2004 EDT Modified files: /php-src/ext/xsl xsltprocessor.c /php-src/ext/xsl/tests xslt011.phpt xslt011.xsl Log: - make static methods calls work from within xslt - extended tests http://cvs.php.net/diff.php/php-src/ext/xsl/xsltprocessor.c?r1=1.26&r2=1.27&ty=u Index: php-src/ext/xsl/xsltprocessor.c diff -u php-src/ext/xsl/xsltprocessor.c:1.26 php-src/ext/xsl/xsltprocessor.c:1.27 --- php-src/ext/xsl/xsltprocessor.c:1.26 Sun Mar 28 10:35:01 2004 +++ php-src/ext/xsl/xsltprocessor.c Tue Apr 20 05:24:23 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xsltprocessor.c,v 1.26 2004/03/28 15:35:01 helly Exp $ */ +/* $Id: xsltprocessor.c,v 1.27 2004/04/20 09:24:23 chregu Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -142,7 +142,8 @@ zval handler; xmlXPathObjectPtr obj; char *str; - + char *callable = NULL; + TSRMLS_FETCH(); tctxt = xsltXPathGetTransformContext(ctxt); @@ -243,29 +244,34 @@ fci.retval_ptr_ptr = &retval; fci.no_separation = 0; /*fci.function_handler_cache = &function_ptr;*/ - - result = zend_call_function(&fci, NULL TSRMLS_CC); - if (result == FAILURE) { - if (Z_TYPE(handler) == IS_STRING) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(&handler)); - } + if (!zend_make_callable(&handler, &callable TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", callable); + efree(callable); + } else { - if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) { - xmlNode *nodep; - dom_object *obj; - obj = (dom_object *)zend_object_store_get_object(retval TSRMLS_CC); - nodep = dom_object_get_node(obj); - valuePush(ctxt, xmlXPathNewNodeSet(nodep)); - } else if (retval->type == IS_BOOL) { - valuePush(ctxt, xmlXPathNewBoolean(retval->value.lval)); - } else if (retval->type == IS_OBJECT) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object can not be converted to a XPath-string"); - valuePush(ctxt, xmlXPathNewString("")); + result = zend_call_function(&fci, NULL TSRMLS_CC); + if (result == FAILURE) { + if (Z_TYPE(handler) == IS_STRING) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(&handler)); + } } else { - convert_to_string_ex(&retval); - valuePush(ctxt, xmlXPathNewString( Z_STRVAL_P(retval))); + if (retval->type == IS_OBJECT && instanceof_function( Z_OBJCE_P(retval), dom_node_class_entry TSRMLS_CC)) { + xmlNode *nodep; + dom_object *obj; + obj = (dom_object *)zend_object_store_get_object(retval TSRMLS_CC); + nodep = dom_object_get_node(obj); + valuePush(ctxt, xmlXPathNewNodeSet(nodep)); + } else if (retval->type == IS_BOOL) { + valuePush(ctxt, xmlXPathNewBoolean(retval->value.lval)); + } else if (retval->type == IS_OBJECT) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "A PHP Object can not be converted to a XPath-string"); + valuePush(ctxt, xmlXPathNewString("")); + } else { + convert_to_string_ex(&retval); + valuePush(ctxt, xmlXPathNewString( Z_STRVAL_P(retval))); + } + zval_ptr_dtor(&retval); } - zval_ptr_dtor(&retval); } zval_dtor(&handler); for (i = 0; i < nargs - 1; i++) { http://cvs.php.net/diff.php/php-src/ext/xsl/tests/xslt011.phpt?r1=1.8&r2=1.9&ty=u Index: php-src/ext/xsl/tests/xslt011.phpt diff -u php-src/ext/xsl/tests/xslt011.phpt:1.8 php-src/ext/xsl/tests/xslt011.phpt:1.9 --- php-src/ext/xsl/tests/xslt011.phpt:1.8 Wed Apr 7 12:48:11 2004 +++ php-src/ext/xsl/tests/xslt011.phpt Tue Apr 20 05:24:24 2004 @@ -39,6 +39,13 @@ function nonDomNode() { return new foo(); } + + class aClass { + static function aStaticFunction($id) { + return $id; + } + } + --EXPECTF-- Test 11: php:function Support @@ -48,4 +55,5 @@ foobar - this is from an external DomDocument from the Input Document +static http://cvs.php.net/diff.php/php-src/ext/xsl/tests/xslt011.xsl?r1=1.3&r2=1.4&ty=u Index: php-src/ext/xsl/tests/xslt011.xsl diff -u php-src/ext/xsl/tests/xslt011.xsl:1.3 php-src/ext/xsl/tests/xslt011.xsl:1.4 --- php-src/ext/xsl/tests/xslt011.xsl:1.3 Sun Jan 18 07:30:52 2004 +++ php-src/ext/xsl/tests/xslt011.xsl Tue Apr 20 05:24:24 2004 @@ -16,6 +16,10 @@ <xsl:value-of select="php:function('nodeSet',/doc)/i"/> <xsl:text> </xsl:text> +<xsl:value-of select="php:function('aClass::aStaticFunction','static')"/> +<xsl:text> +</xsl:text> + <xsl:value-of select="php:function('nonDomNode')"/> </xsl:template> </xsl:stylesheet>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php