php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_iterators.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 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 | Author: Wez Furlong <wez@thebrainroom.com> |
16 | Marcus Boerger <helly@php.net> |
17 +----------------------------------------------------------------------+
18*/
19
20#include "zend.h"
21#include "zend_API.h"
22
23static zend_class_entry zend_iterator_class_entry;
24
25static void iter_wrapper_free(zend_object *object);
26static void iter_wrapper_dtor(zend_object *object);
27static HashTable *iter_wrapper_get_gc(zend_object *object, zval **table, int *n);
28
29static const zend_object_handlers iterator_object_handlers = {
30 0,
31 iter_wrapper_free,
32 iter_wrapper_dtor,
33 NULL, /* clone_obj */
34 NULL, /* prop read */
35 NULL, /* prop write */
36 NULL, /* read dim */
37 NULL, /* write dim */
38 NULL, /* get_property_ptr_ptr */
39 NULL, /* has prop */
40 NULL, /* unset prop */
41 NULL, /* has dim */
42 NULL, /* unset dim */
43 NULL, /* props get */
44 NULL, /* method get */
45 NULL, /* get ctor */
46 NULL, /* get class name */
47 NULL, /* cast */
48 NULL, /* count */
49 NULL, /* get_debug_info */
50 NULL, /* get_closure */
51 iter_wrapper_get_gc,
52 NULL, /* do_operation */
53 NULL, /* compare */
54 NULL /* get_properties_for */
55};
56
58{
59 INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
60 zend_iterator_class_entry.default_object_handlers = &iterator_object_handlers;
61}
62
63static void iter_wrapper_free(zend_object *object)
64{
66 iter->funcs->dtor(iter);
67}
68
69static void iter_wrapper_dtor(zend_object *object)
70{
71}
72
73static HashTable *iter_wrapper_get_gc(zend_object *object, zval **table, int *n) {
75 if (iter->funcs->get_gc) {
76 return iter->funcs->get_gc(iter, table, n);
77 }
78
79 *table = NULL;
80 *n = 0;
81 return NULL;
82}
83
85{
86 zend_object_std_init(&iter->std, &zend_iterator_class_entry);
87}
88
90{
91 if (GC_DELREF(&iter->std) > 0) {
92 return;
93 }
94
96}
97
99{
100 ZEND_ASSERT(Z_TYPE_P(array_ptr) == IS_OBJECT);
101 if (Z_OBJ_HT_P(array_ptr) == &iterator_object_handlers) {
102 return (zend_object_iterator *)Z_OBJ_P(array_ptr);
103 }
104 return NULL;
105}
zend_long n
Definition ffi.c:4979
#define NULL
Definition gdcache.h:45
void(* dtor)(zend_object_iterator *iter)
HashTable *(* get_gc)(zend_object_iterator *iter, zval **table, int *n)
const zend_object_iterator_funcs * funcs
#define INIT_CLASS_ENTRY(class_container, class_name, functions)
Definition zend_API.h:279
struct _zval_struct zval
#define ZEND_API
ZEND_API void zend_register_iterator_wrapper(void)
ZEND_API zend_object_iterator * zend_iterator_unwrap(zval *array_ptr)
ZEND_API void zend_iterator_init(zend_object_iterator *iter)
ZEND_API void zend_iterator_dtor(zend_object_iterator *iter)
struct _zend_object_iterator zend_object_iterator
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce)
ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object)
#define ZEND_ASSERT(c)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
struct _zend_array HashTable
Definition zend_types.h:386
#define Z_OBJ_P(zval_p)
Definition zend_types.h:990
#define Z_OBJ_HT_P(zval_p)
Definition zend_types.h:993
#define GC_DELREF(p)
Definition zend_types.h:710
#define IS_OBJECT
Definition zend_types.h:608
struct _zend_object_handlers zend_object_handlers
Definition zend_types.h:88