This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iterator.c
63 lines (50 loc) · 1.85 KB
/
iterator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
+------------------------------------------------------------------------+
| Zephir Language |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2014 Zephir Team (http://www.zephir-lang.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <[email protected]> |
| Eduar Carvajal <[email protected]> |
| Vladimir Kolesnikov <[email protected]> |
+------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#ifdef PHP_WIN32
#include "php_string.h"
#endif
#include "php_ext.h"
#include "kernel/main.h"
#include "kernel/memory.h"
/**
* Returns an iterator from the object
*/
zend_object_iterator *zephir_get_iterator(zval *iterator TSRMLS_DC) {
zend_class_entry *ce;
zend_object_iterator *it;
if (Z_TYPE_P(iterator) != IS_OBJECT) {
return NULL;
}
ce = Z_OBJCE_P(iterator);
it = ce->get_iterator(ce, iterator, 0 TSRMLS_CC);
if (!it || EG(exception)) {
return NULL;
}
if (it->funcs->get_current_key == NULL) {
return NULL;
}
if (it->funcs->rewind == NULL) {
return NULL;
}
return it;
}