Commit:    2c5ecb4fea3580dfe7e89be7b236b1cacbaf80de
Author:    Nikita Popov <ni...@php.net>         Wed, 23 May 2012 16:07:15 +0200
Parents:   9ce9a7e639bbb6c1c4bb34d542d2ac4e42e9457e
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=2c5ecb4fea3580dfe7e89be7b236b1cacbaf80de

Log:
Add dummy Iterator implementation

This simply adds dummy rewind/valid/current/key/next methods to Generator.

Changed paths:
  M  Zend/zend_generators.c


Diff:
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index d9ddd75..00af655 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -20,6 +20,7 @@
 
 #include "zend.h"
 #include "zend_API.h"
+#include "zend_interfaces.h"
 #include "zend_generators.h"
 
 ZEND_API zend_class_entry *zend_ce_generator;
@@ -85,7 +86,65 @@ static zend_function *zend_generator_get_constructor(zval 
*object TSRMLS_DC) /*
 }
 /* }}} */
 
+/* {{{ proto void Generator::rewind()
+ * Rewind the generator */
+ZEND_METHOD(Generator, rewind)
+{
+       if (zend_parse_parameters_none() == FAILURE) {
+               return;
+       }
+}
+/* }}} */
+
+/* {{{ proto bool Generator::valid()
+ * Check whether the generator is valid */
+ZEND_METHOD(Generator, valid)
+{
+       if (zend_parse_parameters_none() == FAILURE) {
+               return;
+       }
+}
+/* }}} */
+
+/* {{{ proto mixed Generator::current()
+ * Get the current value */
+ZEND_METHOD(Generator, current)
+{
+       if (zend_parse_parameters_none() == FAILURE) {
+               return;
+       }
+}
+/* }}} */
+
+/* {{{ proto mixed Generator::key()
+ * Get the current key */
+ZEND_METHOD(Generator, key)
+{
+       if (zend_parse_parameters_none() == FAILURE) {
+               return;
+       }
+}
+/* }}} */
+
+/* {{{ proto void Generator::next()
+ * Advances the generator */
+ZEND_METHOD(Generator, next)
+{
+       if (zend_parse_parameters_none() == FAILURE) {
+               return;
+       }
+}
+/* }}} */
+
+ZEND_BEGIN_ARG_INFO(arginfo_generator_void, 0)
+ZEND_END_ARG_INFO()
+
 static const zend_function_entry generator_functions[] = {
+       ZEND_ME(Generator, rewind,  arginfo_generator_void, ZEND_ACC_PUBLIC)
+       ZEND_ME(Generator, valid,   arginfo_generator_void, ZEND_ACC_PUBLIC)
+       ZEND_ME(Generator, current, arginfo_generator_void, ZEND_ACC_PUBLIC)
+       ZEND_ME(Generator, key,     arginfo_generator_void, ZEND_ACC_PUBLIC)
+       ZEND_ME(Generator, next,    arginfo_generator_void, ZEND_ACC_PUBLIC)
        ZEND_FE_END
 };
 
@@ -98,6 +157,8 @@ void zend_register_generator_ce(TSRMLS_D) /* {{{ */
        zend_ce_generator->ce_flags |= ZEND_ACC_FINAL_CLASS;
        zend_ce_generator->create_object = zend_generator_create;
 
+       zend_class_implements(zend_ce_generator TSRMLS_CC, 1, zend_ce_iterator);
+
        memcpy(&zend_generator_handlers, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
        zend_generator_handlers.get_constructor = 
zend_generator_get_constructor;
 }


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to