1 /* 2 +----------------------------------------------------------------------+ 3 | Zend Engine | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 2.00 of the Zend license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.zend.com/license/2_00.txt. | 11 | If you did not receive a copy of the Zend license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@zend.com so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Nikita Popov <nikic@php.net> | 16 +----------------------------------------------------------------------+ 17 */ 18 19 /* $Id$ */ 20 21 #ifndef ZEND_GENERATORS_H 22 #define ZEND_GENERATORS_H 23 24 BEGIN_EXTERN_C() 25 26 extern ZEND_API zend_class_entry *zend_ce_generator; 27 28 typedef struct _zend_generator_iterator { 29 zend_object_iterator intern; 30 31 /* The generator object handle has to be stored, because the 32 * iterator is holding a ref to it, which has to be dtored. */ 33 zend_object_handle handle; 34 } zend_generator_iterator; 35 36 typedef struct _zend_generator { 37 zend_object std; 38 39 zend_generator_iterator iterator; 40 41 /* The suspended execution context. */ 42 zend_execute_data *execute_data; 43 44 /* The separate stack used by generator */ 45 zend_vm_stack stack; 46 47 /* Current value */ 48 zval *value; 49 /* Current key */ 50 zval *key; 51 /* Variable to put sent value into */ 52 zval **send_target; 53 /* Largest used integer key for auto-incrementing keys */ 54 long largest_used_integer_key; 55 56 /* ZEND_GENERATOR_* flags */ 57 zend_uchar flags; 58 } zend_generator; 59 60 static const zend_uchar ZEND_GENERATOR_CURRENTLY_RUNNING = 0x1; 61 static const zend_uchar ZEND_GENERATOR_FORCED_CLOSE = 0x2; 62 static const zend_uchar ZEND_GENERATOR_AT_FIRST_YIELD = 0x4; 63 64 void zend_register_generator_ce(TSRMLS_D); 65 ZEND_API zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC); 66 ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC); 67 ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC); 68 69 END_EXTERN_C() 70 71 #endif 72 73 /* 74 * Local variables: 75 * tab-width: 4 76 * c-basic-offset: 4 77 * indent-tabs-mode: t 78 * End: 79 */ 80