For Programmers: Free Programming Magazines  


Home > Archive > PHP Zend Engine > April 2004 > cvs: ZendEngine2 / zend_builtin_functions.c









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cvs: ZendEngine2 / zend_builtin_functions.c
Marcus Boerger

2004-04-27, 3:02 pm

helly Tue Apr 27 14:09:40 2004 EDT

Modified files:
/ZendEngine2 zend_builtin_functions.c
Log:
- Optional parameter to class_exists() that can be used to bypass
__autoload() which can be helpfull in __autoload() itself.


http://cvs.php.net/diff.php/ZendEng...4&r2=1.235&ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.234 ZendEngine2/zend_builtin_functions.c:1.235
--- ZendEngine2/zend_builtin_functions.c:1.234 Sun Apr 25 07:28:46 2004
+++ ZendEngine2/zend_builtin_functions.c Tue Apr 27 14:09:40 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: zend_builtin_functions.c,v 1.234 2004/04/25 11:28:46 helly Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.235 2004/04/27 18:09:40 helly Exp $ */

#include "zend.h"
#include "zend_API.h"
@@ -799,20 +799,30 @@
}
/* }}} */

-/* {{{ proto bool class_exists(string classname)
+/* {{{ proto bool class_exists(string classname [, bool autoload])
Checks if the class exists */
ZEND_FUNCTION(class_exists)
{
- zval **class_name;
+ char *class_name, *lc_name;
zend_class_entry **ce;
+ long class_name_len;
+ zend_bool autoload = 1;
+ int found;

- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &class_name, &class_name_len, &autoload) == FAILURE) {
+ return;
}

- convert_to_string_ex(class_name);
+ if (!autoload) {
+ lc_name = do_alloca(class_name_len + 1);
+ zend_str_tolower_copy(lc_name, class_name, class_name_len);
+
+ found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce);
+ free_alloca(lc_name);
+ RETURN_BOOL(found == SUCCESS);
+ }

- if (zend_lookup_class(Z_STRVAL_PP(class_nam
e), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == SUCCESS) {
+ if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com