cvs: ZendEngine2(PHP_5_0) / zend_builtin_functions.c

From: Date: Wed, 25 Aug 2004 01:02:39 +0000
Subject: cvs: ZendEngine2(PHP_5_0) / zend_builtin_functions.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2902@lists.php.net to get a copy of this message
andi Tue Aug 24 21:02:39 2004 EDT Modified files: (Branch: PHP_5_0) /ZendEngine2 zend_builtin_functions.c Log: - MFH http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.239.2.5&r2=1.239.2.6&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.239.2.5 ZendEngine2/zend_builtin_functions.c:1.239.2.6 --- ZendEngine2/zend_builtin_functions.c:1.239.2.5 Wed Aug 4 20:44:32 2004 +++ ZendEngine2/zend_builtin_functions.c Tue Aug 24 21:02:38 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.239.2.5 2004/08/05 00:44:32 iliaa Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.239.2.6 2004/08/25 01:02:38 andi Exp $ */ #include "zend.h" #include "zend_API.h" @@ -44,6 +44,7 @@ static ZEND_FUNCTION(get_parent_class); static ZEND_FUNCTION(method_exists); static ZEND_FUNCTION(class_exists); +static ZEND_FUNCTION(interface_exists); static ZEND_FUNCTION(function_exists); #if ZEND_DEBUG static ZEND_FUNCTION(leak); @@ -102,6 +103,7 @@ ZEND_FE(get_parent_class, NULL) ZEND_FE(method_exists, NULL) ZEND_FE(class_exists, NULL) + ZEND_FE(interface_exists, NULL) ZEND_FE(function_exists, NULL) #if ZEND_DEBUG ZEND_FE(leak, NULL) @@ -848,11 +850,42 @@ found = zend_hash_find(EG(class_table), lc_name, class_name_len+1, (void **) &ce); free_alloca(lc_name); - RETURN_BOOL(found == SUCCESS); + RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & ZEND_ACC_INTERFACE)); } if (zend_lookup_class(class_name, class_name_len, &ce TSRMLS_CC) == SUCCESS) { - RETURN_TRUE; + RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) == 0); + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto bool interface_exists(string classname [, bool autoload]) + Checks if the class exists */ +ZEND_FUNCTION(interface_exists) +{ + char *iface_name, *lc_name; + zend_class_entry **ce; + int iface_name_len; + zend_bool autoload = 1; + int found; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &iface_name, &iface_name_len, &autoload) == FAILURE) { + return; + } + + if (!autoload) { + lc_name = do_alloca(iface_name_len + 1); + zend_str_tolower_copy(lc_name, iface_name, iface_name_len); + + found = zend_hash_find(EG(class_table), lc_name, iface_name_len+1, (void **) &ce); + free_alloca(lc_name); + RETURN_BOOL(found == SUCCESS && (*ce)->ce_flags & ZEND_ACC_INTERFACE); + } + + if (zend_lookup_class(iface_name, iface_name_len, &ce TSRMLS_CC) == SUCCESS) { + RETURN_BOOL(((*ce)->ce_flags & ZEND_ACC_INTERFACE) > 0); } else { RETURN_FALSE; }

« previous php.zend-engine.cvs (#2902) next »