Skip to content

Commit 4d43241

Browse files
committed
Move some private SPL Directory elements out of the header
1 parent 365537f commit 4d43241

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

ext/spl/spl_directory.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ PHPAPI zend_class_entry *spl_ce_GlobIterator;
5252
PHPAPI zend_class_entry *spl_ce_SplFileObject;
5353
PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
5454

55+
/* Object helper */
56+
static inline spl_filesystem_object *spl_filesystem_from_obj(zend_object *obj) /* {{{ */ {
57+
return (spl_filesystem_object*)((char*)(obj) - XtOffsetOf(spl_filesystem_object, std));
58+
}
59+
/* }}} */
60+
#define Z_SPLFILESYSTEM_P(zv) spl_filesystem_from_obj(Z_OBJ_P((zv)))
61+
62+
/* define an overloaded iterator structure */
63+
typedef struct {
64+
zend_object_iterator intern;
65+
zval current;
66+
void *object;
67+
} spl_filesystem_iterator;
68+
69+
static inline spl_filesystem_iterator* spl_filesystem_object_to_iterator(spl_filesystem_object *obj)
70+
{
71+
spl_filesystem_iterator *it;
72+
73+
it = ecalloc(1, sizeof(spl_filesystem_iterator));
74+
it->object = (void *)obj;
75+
zend_iterator_init(&it->intern);
76+
return it;
77+
}
78+
79+
static inline spl_filesystem_object* spl_filesystem_iterator_to_object(spl_filesystem_iterator *it)
80+
{
81+
return (spl_filesystem_object*)it->object;
82+
}
83+
5584
#define CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(spl_filesystem_object_pointer) \
5685
if (!(spl_filesystem_object_pointer)->u.file.stream) { \
5786
zend_throw_error(NULL, "Object not initialized"); \

ext/spl/spl_directory.h

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ extern PHPAPI zend_class_entry *spl_ce_SplTempFileObject;
3030

3131
PHP_MINIT_FUNCTION(spl_directory);
3232

33-
typedef enum {
34-
SPL_FS_INFO, /* must be 0 */
35-
SPL_FS_DIR,
36-
SPL_FS_FILE
37-
} SPL_FS_OBJ_TYPE;
38-
33+
/* Internal objecte structure and helpers for Directory and File SPL objects */
3934
typedef struct _spl_filesystem_object spl_filesystem_object;
4035

4136
typedef void (*spl_foreign_dtor_t)(spl_filesystem_object *object);
@@ -48,12 +43,11 @@ typedef struct _spl_other_handler {
4843
spl_foreign_clone_t clone;
4944
} spl_other_handler;
5045

51-
/* define an overloaded iterator structure */
52-
typedef struct {
53-
zend_object_iterator intern;
54-
zval current;
55-
void *object;
56-
} spl_filesystem_iterator;
46+
typedef enum {
47+
SPL_FS_INFO, /* must be 0 */
48+
SPL_FS_DIR,
49+
SPL_FS_FILE
50+
} SPL_FS_OBJ_TYPE;
5751

5852
struct _spl_filesystem_object {
5953
void *oth;
@@ -96,28 +90,6 @@ struct _spl_filesystem_object {
9690
zend_object std;
9791
};
9892

99-
static inline spl_filesystem_object *spl_filesystem_from_obj(zend_object *obj) /* {{{ */ {
100-
return (spl_filesystem_object*)((char*)(obj) - XtOffsetOf(spl_filesystem_object, std));
101-
}
102-
/* }}} */
103-
104-
#define Z_SPLFILESYSTEM_P(zv) spl_filesystem_from_obj(Z_OBJ_P((zv)))
105-
106-
static inline spl_filesystem_iterator* spl_filesystem_object_to_iterator(spl_filesystem_object *obj)
107-
{
108-
spl_filesystem_iterator *it;
109-
110-
it = ecalloc(1, sizeof(spl_filesystem_iterator));
111-
it->object = (void *)obj;
112-
zend_iterator_init(&it->intern);
113-
return it;
114-
}
115-
116-
static inline spl_filesystem_object* spl_filesystem_iterator_to_object(spl_filesystem_iterator *it)
117-
{
118-
return (spl_filesystem_object*)it->object;
119-
}
120-
12193
#define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001 /* drop new lines */
12294
#define SPL_FILE_OBJECT_READ_AHEAD 0x00000002 /* read on rewind/next */
12395
#define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000004 /* skip empty lines */

0 commit comments

Comments
 (0)