helly Fri Oct 24 14:24:29 2003 EDT
Modified files:
/ZendEngine2 ZEND_CHANGES zend_API.c zend_execute_API.c
/php-src/ext/sockets sockets.c
Log:
Zend/ZEND_CHANGES
Index: ZendEngine2/ZEND_CHANGES
diff -u ZendEngine2/ZEND_CHANGES:1.61 ZendEngine2/ZEND_CHANGES:1.62
--- ZendEngine2/ZEND_CHANGES:1.61 Tue Oct 21 02:41:26 2003
+++ ZendEngine2/ZEND_CHANGES Fri Oct 24 14:24:27 2003
@@ -651,6 +651,79 @@
TBD: Respect visibility: Show protected only when inside class
method and only otherwise public properties only.
+ Each class whose instances can be iterated with foreach should
+ implement the empty interface 'Traversable'. Hence any object
+ that says it implements 'Traversable' can be used with forach.
+
+ The interfaces 'IteratorAggregate' and 'Iterator' allow to specify
+ how class objects are iterated in PHP code. The first of them simply
+ has a method 'getIterator' which must return an array or an object
+ that either implements the interface 'Iterator' or is instantiated
+ from an internal class that can be iterated.
+
+ Example:
+
+ <?php
+ class ObjectIterator implements Iterator {
+
+ private $obj;
+ private $num;
+
+ function __construct($obj) {
+ $this->obj = $obj;
+ }
+ function rewind() {
+ $this->num = 0;
+ }
+ function hasMore() {
+ return $this->num < $this->obj->max;
+ }
+ function key() {
+ return $this->num;
+ }
+ function current() {
+ switch($this->num) {
+ case 0: return "1st";
+ case 1: return "2nd";
+ case 2: return "3rd";
+ default: return $this->num."th";
+ }
+ }
+ function next() {
+ $this->num++;
+ }
+ }
+
+ class Oject implements IteratorAggregate {
+
+ public $max = 3;
+
+ function getIterator() {
+ return new ObjectIterator($this);
+ }
+ }
+
+ $obj = new Object;
+
+ // this foreach ...
+ foreach($obj as $key => $val) {
+ echo "$key = $val\n";
+ }
+
+ // matches the following 7 lines with the for directive.
+ $it = $obj->getIterator();
+ for($it->rewind(); $it->hasMore(); $it->next) {
+ $key = $it->current();
+ $val = $it->key();
+ echo "$key = $val\n";
+ }
+ unset($it);
+ ?>
+
+ The matching for directive is very intersting here since it shows
+ the use of all abstract methods declared in the interfaces Iterator
+ and IteratorAggregate respectively.
+
* __METHOD__
The pseudo constant __METHOD__ shows the current class and method
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.221 ZendEngine2/zend_API.c:1.222
--- ZendEngine2/zend_API.c:1.221 Wed Oct 22 15:59:58 2003
+++ ZendEngine2/zend_API.c Fri Oct 24 14:24:27 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.221 2003/10/22 19:59:58 helly Exp $ */
+/* $Id: zend_API.c,v 1.222 2003/10/24 18:24:27 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1588,8 +1588,23 @@
return 1;
lcname = zend_str_tolower_dup(Z_STRVAL_P(callable),
Z_STRLEN_P(callable));
- if (zend_hash_exists(EG(function_table), lcname,
Z_STRLEN_P(callable)+1))
+ if (zend_hash_exists(EG(function_table), lcname,
Z_STRLEN_P(callable)+1)) {
retval = 1;
+ } else {
+ char *func_pos;
+ if ((func_pos=strstr(lcname, "::"))) {
+ int lcclass_len = (int)(func_pos - lcname);
+ char *lcclass = estrndup(lcname, lcclass_len);
+ zend_class_entry **ce;
+
+ if (zend_lookup_class(lcclass, lcclass_len,
&ce TSRMLS_CC) == SUCCESS) {
+ int func_len = Z_STRLEN_P(callable) -
lcclass_len - 2;
+ func_pos += 2;
+ retval =
zend_hash_exists(&(*ce)->function_table, func_pos, func_len + 1) ? 1 : 0;
+ }
+ efree(lcclass);
+ }
+ }
efree(lcname);
break;
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.237 ZendEngine2/zend_execute_API.c:1.238
--- ZendEngine2/zend_execute_API.c:1.237 Tue Oct 14 10:36:23 2003
+++ ZendEngine2/zend_execute_API.c Fri Oct 24 14:24:27 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.237 2003/10/14 14:36:23 stas Exp $ */
+/* $Id: zend_execute_API.c,v 1.238 2003/10/24 18:24:27 helly Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -532,7 +532,8 @@
zend_execute_data execute_data;
zval *method_name;
zval *params_array;
- int call_via_handler = 0;
+ int call_via_handler = 0, success;
+ char *func_pos;
switch (fci->size) {
case sizeof(zend_fcall_info):
@@ -616,7 +617,26 @@
function_name_lc =
zend_str_tolower_dup(fci->function_name->value.str.val,
fci->function_name->value.str.len);
- if (zend_hash_find(fci->function_table, function_name_lc,
fci->function_name->value.str.len+1, (void **) &EX(function_state).function)==FAILURE)
{
+ success = zend_hash_find(fci->function_table, function_name_lc,
fci->function_name->value.str.len+1, (void **) &EX(function_state).function);
+ if (success==FAILURE && !fci->object_pp &&
(func_pos=strstr(function_name_lc, "::"))) {
+ int class_name_lc_len = (int)(func_pos - function_name_lc);
+ char *class_name_lc = estrndup(function_name_lc,
class_name_lc_len);
+ zend_class_entry **ce;
+
+ success = zend_lookup_class(class_name_lc, class_name_lc_len,
&ce TSRMLS_CC);
+
+ efree(class_name_lc);
+ if (success == SUCCESS) {
+ int func_len = fci->function_name->value.str.len -
class_name_lc_len - 2;
+ func_pos += 2;
+ fci->function_table = &(*ce)->function_table;
+ calling_scope = *ce;
+ fci->object_pp = NULL;
+ success = zend_hash_find(fci->function_table,
func_pos, func_len + 1, (void **) &EX(function_state).function);
+ }
+ }
+
+ if (success==FAILURE) {
/* try calling __call */
if (calling_scope && calling_scope->__call) {
EX(function_state).function = calling_scope->__call;
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.153 php-src/ext/sockets/sockets.c:1.154
--- php-src/ext/sockets/sockets.c:1.153 Sun Aug 31 16:45:48 2003
+++ php-src/ext/sockets/sockets.c Fri Oct 24 14:24:28 2003
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sockets.c,v 1.153 2003/08/31 20:45:48 iliaa Exp $ */
+/* $Id: sockets.c,v 1.154 2003/10/24 18:24:28 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -107,17 +107,6 @@
ZEND_ARG_PASS_INFO(1)
ZEND_ARG_PASS_INFO(0)
ZEND_ARG_PASS_INFO(0)
- ZEND_ARG_PASS_INFO(1)
- ZEND_ARG_PASS_INFO(1)
- ZEND_END_ARG_INFO();
-
-static
- ZEND_BEGIN_ARG_INFO(third_through_seventh_args_force_ref, 0)
- ZEND_ARG_PASS_INFO(0)
- ZEND_ARG_PASS_INFO(0)
- ZEND_ARG_PASS_INFO(1)
- ZEND_ARG_PASS_INFO(1)
- ZEND_ARG_PASS_INFO(1)
ZEND_ARG_PASS_INFO(1)
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php