Patch generator_reply.diff for *General Issues Bug #77343
Patch version 2018-12-23 21:44 UTC
Return to Bug #77343 |
Download this patch
Patch Revisions:
Developer: stephan.soller@helionweb.de
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 9f6f80f6..fe9caa01 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -1004,6 +1004,34 @@ ZEND_METHOD(Generator, send)
}
/* }}} */
+/* {{{ proto mixed Generator::reply(mixed value)
+ * Sets the return value of the current yield expression in the generator */
+ZEND_METHOD(Generator, reply)
+{
+ zval *value;
+ zend_generator *generator, *root;
+
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_ZVAL(value)
+ ZEND_PARSE_PARAMETERS_END();
+
+ generator = (zend_generator *) Z_OBJ_P(ZEND_THIS);
+
+ zend_generator_ensure_initialized(generator);
+
+ /* The generator is already closed, thus can't send anything */
+ if (UNEXPECTED(!generator->execute_data)) {
+ return;
+ }
+
+ root = zend_generator_get_current(generator);
+ /* Put sent value in the target VAR slot, if it is used */
+ if (root->send_target) {
+ ZVAL_COPY(root->send_target, value);
+ }
+}
+/* }}} */
+
/* {{{ proto mixed Generator::throw(Exception exception)
* Throws an exception into the generator */
ZEND_METHOD(Generator, throw)
@@ -1183,6 +1211,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_generator_send, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_generator_reply, 0, 0, 1)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_generator_throw, 0, 0, 1)
ZEND_ARG_INFO(0, exception)
ZEND_END_ARG_INFO()
@@ -1194,6 +1226,7 @@ static const zend_function_entry generator_functions[] = {
ZEND_ME(Generator, key, arginfo_generator_void, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, next, arginfo_generator_void, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, send, arginfo_generator_send, ZEND_ACC_PUBLIC)
+ ZEND_ME(Generator, reply, arginfo_generator_reply, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, throw, arginfo_generator_throw, ZEND_ACC_PUBLIC)
ZEND_ME(Generator, getReturn,arginfo_generator_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
|