cvs: ZendEngine2 / zend_API.c zend_API.h
| From: | Marcus Boerger | Date: | Sat, 25 Oct 2003 22:58:06 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_API.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1942@lists.php.net to get a copy of this message | ||
helly Sat Oct 25 18:58:06 2003 EDT
Modified files:
/ZendEngine2 zend_API.c zend_API.h
Log:
Add zend_make_callable() which allows to make zval's callable zval's.
At the moment this function only converts strings of the form class::method
to an array(class,method).
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.223 ZendEngine2/zend_API.c:1.224
--- ZendEngine2/zend_API.c:1.223 Fri Oct 24 14:42:00 2003
+++ ZendEngine2/zend_API.c Sat Oct 25 18:58:06 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.223 2003/10/24 18:42:00 helly Exp $ */
+/* $Id: zend_API.c,v 1.224 2003/10/25 22:58:06 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1573,7 +1573,7 @@
return 1;
}
-zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name)
+ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name)
{
char *lcname;
zend_bool retval = 0;
@@ -1681,6 +1681,33 @@
break;
}
+ return retval;
+}
+
+
+ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRMLS_DC)
+{
+ char *lcname, *func;
+ zend_bool retval = 0;
+
+ if (zend_is_callable(callable, 0, callable_name)) {
+ return 1;
+ }
+ switch (Z_TYPE_P(callable)) {
+ case IS_STRING:
+ lcname = zend_str_tolower_dup(Z_STRVAL_P(callable), Z_STRLEN_P(callable));
+
+ if ((func = strstr(lcname, "::")) != NULL) {
+ zval_dtor(callable);
+ array_init(callable);
+ add_next_index_stringl(callable, lcname, func - lcname, 1);
+ func += 2;
+ add_next_index_stringl(callable, func, strlen(func), 1);
+ retval = 1;
+ }
+ efree(lcname);
+ break;
+ }
return retval;
}
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.167 ZendEngine2/zend_API.h:1.168
--- ZendEngine2/zend_API.h:1.167 Wed Oct 22 15:59:58 2003
+++ ZendEngine2/zend_API.h Sat Oct 25 18:58:06 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.167 2003/10/22 19:59:58 helly Exp $ */
+/* $Id: zend_API.h,v 1.168 2003/10/25 22:58:06 helly Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -169,6 +169,7 @@
ZEND_API void zend_wrong_param_count(TSRMLS_D);
ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only, char **callable_name);
+ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name TSRMLS_DC);
ZEND_API char *zend_get_module_version(char *module_name);
ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval
*property, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int
access_type TSRMLS_DC);