helly           Thu Jul 28 16:59:45 2005 EDT

  Modified files:              
    /php-src/ext/spl    php_spl.c 
  Log:
  - Allow static loader functions (but only for 5.1.1 as discussed with Andi)
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.49&r2=1.50&ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.49 php-src/ext/spl/php_spl.c:1.50
--- php-src/ext/spl/php_spl.c:1.49      Fri Jun 17 12:42:53 2005
+++ php-src/ext/spl/php_spl.c   Thu Jul 28 16:59:44 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c,v 1.49 2005/06/17 16:42:53 sniper Exp $ */
+/* $Id: php_spl.c,v 1.50 2005/07/28 20:59:44 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
        #include "config.h"
@@ -356,16 +356,33 @@
  Register given function as __autoload() implementation */
 PHP_FUNCTION(spl_autoload_register)
 {
-       char *func_name, *lc_name;
+       char *func_name, *lc_name = NULL;
+       zval *zcallable = NULL;
        int func_name_len;
        zend_bool do_throw = 1;
        zend_function *spl_func_ptr, *func_ptr, **func_ptr_ptr;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sb", &func_name, 
&func_name_len, &do_throw) == FAILURE) {
-               return;
-       }
-       
-       if (ZEND_NUM_ARGS()) {
+       if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
TSRMLS_CC, "|sb", &func_name, &func_name_len, &do_throw) == FAILURE) {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", 
&zcallable, &func_name_len, &do_throw) == FAILURE) {
+                       return;
+               }
+#if MBO_0
+               if (!zend_is_callable_ex(zcallable, 
IS_CALLABLE_CHECK_IS_STATIC, &func_name, &func_name_len, &func_ptr, NULL 
TSRMLS_CC)) {
+                       if (do_throw) {
+                               if (func_ptr) {
+                                       
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Non static methods 
are not supported yet");
+                               } else {
+                                       
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Passed array does 
not specify a callable method or method");
+                               }
+                       }
+                       return;
+               }
+               lc_name = do_alloca(func_name_len + 1);
+               zend_str_tolower_copy(lc_name, func_name, func_name_len);
+#else
+               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Loader methods are 
not yet supported");
+#endif
+       } else if (ZEND_NUM_ARGS()) {
                lc_name = do_alloca(func_name_len + 1);
                zend_str_tolower_copy(lc_name, func_name, func_name_len);
                
@@ -384,7 +401,9 @@
                        free_alloca(lc_name);
                        return;
                }
-               
+       }
+       
+       if (ZEND_NUM_ARGS()) {
                if (!SPL_G(autoload_functions)) {
                        ALLOC_HASHTABLE(SPL_G(autoload_functions));
                        zend_hash_init(SPL_G(autoload_functions), 1, NULL, 
NULL, 0);
@@ -473,7 +492,19 @@
                zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), 
&function_pos);
                while(zend_hash_has_more_elements_ex(SPL_G(autoload_functions), 
&function_pos) == SUCCESS) {
                        
zend_hash_get_current_data_ex(SPL_G(autoload_functions), (void **) 
&func_ptr_ptr, &function_pos);
-                       add_next_index_string(return_value, 
(*func_ptr_ptr)->common.function_name, 1);
+#if MBO_0
+                       if ((*func_ptr_ptr)->common.scope) {
+                               zval *tmp;
+                               MAKE_STD_ZVAL(tmp);
+                               array_init(tmp);
+
+                               add_next_index_string(tmp, 
(*func_ptr_ptr)->common.scope->name, 1);
+                               add_next_index_string(tmp, 
(*func_ptr_ptr)->common.function_name, 1);
+                               add_next_index_zval(return_value, tmp);
+                       } else
+#endif
+                               add_next_index_string(return_value, 
(*func_ptr_ptr)->common.function_name, 1);
+
                        zend_hash_move_forward_ex(SPL_G(autoload_functions), 
&function_pos);
                }
                return;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to