diff options
| author | Andi Gutmans <andi@php.net> | 2002-06-26 15:13:14 +0000 | 
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2002-06-26 15:13:14 +0000 | 
| commit | 737de1bd0c19a1b77808affe8ba6d945e7ac831b (patch) | |
| tree | 76cf2ee4ebcf2c6874f70362459329f5005078a8 /Zend/zend_execute_API.c | |
| parent | 28247f572a226c9e58d9c1593e7be8dae8da8bd8 (diff) | |
| download | php-git-737de1bd0c19a1b77808affe8ba6d945e7ac831b.tar.gz | |
- Autoloading support based on patch from Ivan Ristic.
- Again I hope this feature ends up working well because if it doesn't we
- might need to nuke it. This only works for global scoped classes and it
- will never work for sub-classes so don't even ask!!!!!
- Just define an __autoload() function in the global scope and it will be
- called with the class name as the parameter if it doesn't manage to find
- the class.
Diffstat (limited to 'Zend/zend_execute_API.c')
| -rw-r--r-- | Zend/zend_execute_API.c | 31 | 
1 files changed, 29 insertions, 2 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 36596e0228..d6120bf7ce 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -639,9 +639,36 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun  ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC)  { -	return zend_hash_find(EG(class_table), name, name_length+1, (void **) ce); -} +	zval **args[1]; +	zval *autoload_function; +	zval *class_name; +	zval *retval_ptr; +	int retval; + +	if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { +		return SUCCESS; +	} + +	MAKE_STD_ZVAL(autoload_function); +	ZVAL_STRINGL(autoload_function, "__autoload", sizeof("__autoload")-1,  1); + +	MAKE_STD_ZVAL(class_name); +	ZVAL_STRINGL(class_name, name, name_length, 1); +	args[0] = &class_name; + +	retval = call_user_function_ex(EG(function_table), NULL, autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC); +	zval_ptr_dtor(&autoload_function); +	zval_ptr_dtor(&class_name); +	 +	if (retval == FAILURE) { +		return FAILURE; +	} + +	zval_ptr_dtor(&retval_ptr); + +	return zend_hash_find(EG(class_table), name, name_length + 1, (void **) ce);		 +}  ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC)  {  | 
