summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2012-05-23 16:07:15 +0200
committerNikita Popov <nikic@php.net>2012-05-23 16:44:58 +0200
commit2c5ecb4fea3580dfe7e89be7b236b1cacbaf80de (patch)
treee4cb238024fb6f70d311efba5e0295707d8ea1a7
parent9ce9a7e639bbb6c1c4bb34d542d2ac4e42e9457e (diff)
downloadphp-git-2c5ecb4fea3580dfe7e89be7b236b1cacbaf80de.tar.gz
Add dummy Iterator implementation
This simply adds dummy rewind/valid/current/key/next methods to Generator.
-rw-r--r--Zend/zend_generators.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index d9ddd75ffb..00af65538a 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;
}