zend_generators.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /* $Id$ */
  19. #ifndef ZEND_GENERATORS_H
  20. #define ZEND_GENERATORS_H
  21. BEGIN_EXTERN_C()
  22. extern ZEND_API zend_class_entry *zend_ce_generator;
  23. typedef struct _zend_generator_iterator {
  24. zend_object_iterator intern;
  25. /* The generator object handle has to be stored, because the
  26. * iterator is holding a ref to it, which has to be dtored. */
  27. zend_object_handle handle;
  28. } zend_generator_iterator;
  29. typedef struct _zend_generator {
  30. zend_object std;
  31. zend_generator_iterator iterator;
  32. /* The suspended execution context. */
  33. zend_execute_data *execute_data;
  34. /* The separate stack used by generator */
  35. zend_vm_stack stack;
  36. /* Current value */
  37. zval *value;
  38. /* Current key */
  39. zval *key;
  40. /* Variable to put sent value into */
  41. zval **send_target;
  42. /* Largest used integer key for auto-incrementing keys */
  43. long largest_used_integer_key;
  44. /* ZEND_GENERATOR_* flags */
  45. zend_uchar flags;
  46. } zend_generator;
  47. static const zend_uchar ZEND_GENERATOR_CURRENTLY_RUNNING = 0x1;
  48. static const zend_uchar ZEND_GENERATOR_FORCED_CLOSE = 0x2;
  49. static const zend_uchar ZEND_GENERATOR_AT_FIRST_YIELD = 0x4;
  50. void zend_register_generator_ce(TSRMLS_D);
  51. ZEND_API zval *zend_generator_create_zval(zend_op_array *op_array TSRMLS_DC);
  52. ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished_execution TSRMLS_DC);
  53. ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC);
  54. END_EXTERN_C()
  55. #endif
  56. /*
  57. * Local variables:
  58. * tab-width: 4
  59. * c-basic-offset: 4
  60. * indent-tabs-mode: t
  61. * End:
  62. */