mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/spl: Remove spl_engine.h header (#14418)
And convert calls to spl_instantiate_arg_* to the new object_init_with_constructor() API
This commit is contained in:
parent
d8795a3503
commit
a5cacba6d8
12 changed files with 101 additions and 113 deletions
|
@ -52,7 +52,6 @@
|
|||
#include "Zend/zend_virtual_cwd.h"
|
||||
#include "ext/spl/spl_array.h"
|
||||
#include "ext/spl/spl_directory.h"
|
||||
#include "ext/spl/spl_engine.h"
|
||||
#include "ext/spl/spl_exceptions.h"
|
||||
#include "ext/spl/spl_iterators.h"
|
||||
#include "php_phar.h"
|
||||
|
|
|
@ -3540,9 +3540,7 @@ PHP_METHOD(Phar, offsetGet)
|
|||
{
|
||||
char *fname, *error;
|
||||
size_t fname_len;
|
||||
zval zfname;
|
||||
phar_entry_info *entry;
|
||||
zend_string *sfname;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
|
@ -3574,10 +3572,16 @@ PHP_METHOD(Phar, offsetGet)
|
|||
efree(entry);
|
||||
}
|
||||
|
||||
sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
|
||||
zend_string *sfname = strpprintf(0, "phar://%s/%s", phar_obj->archive->fname, fname);
|
||||
zval zfname;
|
||||
ZVAL_NEW_STR(&zfname, sfname);
|
||||
spl_instantiate_arg_ex1(phar_obj->spl.info_class, return_value, &zfname);
|
||||
|
||||
/* Instantiate object and call constructor */
|
||||
zend_result is_initialized = object_init_with_constructor(return_value, phar_obj->spl.info_class, 1, &zfname, NULL);
|
||||
zval_ptr_dtor(&zfname);
|
||||
if (is_initialized == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
|
||||
PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
|
||||
PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
|
||||
PHP_ADD_EXTENSION_DEP(spl, pcre, true)
|
||||
PHP_ADD_EXTENSION_DEP(spl, standard, true)
|
||||
PHP_ADD_EXTENSION_DEP(spl, json)
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
EXTENSION("spl", "php_spl.c spl_functions.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
|
||||
PHP_SPL="yes";
|
||||
PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");
|
||||
PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "php_spl.h"
|
||||
#include "php_spl_arginfo.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_array.h"
|
||||
#include "spl_directory.h"
|
||||
#include "spl_iterators.h"
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "php_spl.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_iterators.h"
|
||||
#include "spl_directory.h"
|
||||
#include "spl_directory_arginfo.h"
|
||||
|
@ -1516,7 +1515,6 @@ PHP_METHOD(RecursiveDirectoryIterator, hasChildren)
|
|||
/* {{{ Returns an iterator for the current entry if it is a directory */
|
||||
PHP_METHOD(RecursiveDirectoryIterator, getChildren)
|
||||
{
|
||||
zval zpath, zflags;
|
||||
spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS));
|
||||
spl_filesystem_object *subdir;
|
||||
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
|
||||
|
@ -1529,10 +1527,15 @@ PHP_METHOD(RecursiveDirectoryIterator, getChildren)
|
|||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
ZVAL_LONG(&zflags, intern->flags);
|
||||
ZVAL_STR_COPY(&zpath, intern->file_name);
|
||||
spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &zpath, &zflags);
|
||||
zval_ptr_dtor(&zpath);
|
||||
zval params[2];
|
||||
ZVAL_STR_COPY(¶ms[0], intern->file_name);
|
||||
ZVAL_LONG(¶ms[1], intern->flags);
|
||||
|
||||
zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 2, params, NULL);
|
||||
zval_ptr_dtor_str(¶ms[0]);
|
||||
if (is_initialized == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
subdir = spl_filesystem_from_obj(Z_OBJ_P(return_value));
|
||||
if (subdir) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "zend_interfaces.h"
|
||||
#include "zend_exceptions.h"
|
||||
#include "zend_hash.h"
|
||||
|
||||
|
@ -26,7 +27,6 @@
|
|||
#include "ext/standard/php_var.h"
|
||||
#include "zend_smart_str.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_iterators.h"
|
||||
#include "spl_dllist.h"
|
||||
#include "spl_dllist_arginfo.h"
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| https://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Marcus Boerger <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef SPL_ENGINE_H
|
||||
#define SPL_ENGINE_H
|
||||
|
||||
#include "php.h"
|
||||
#include "php_spl.h"
|
||||
#include "zend_interfaces.h"
|
||||
|
||||
static inline void spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1)
|
||||
{
|
||||
object_init_ex(retval, pce);
|
||||
zend_call_known_instance_method_with_1_params(pce->constructor, Z_OBJ_P(retval), NULL, arg1);
|
||||
}
|
||||
|
||||
static inline void spl_instantiate_arg_ex2(
|
||||
zend_class_entry *pce, zval *retval, zval *arg1, zval *arg2)
|
||||
{
|
||||
object_init_ex(retval, pce);
|
||||
zend_call_known_instance_method_with_2_params(
|
||||
pce->constructor, Z_OBJ_P(retval), NULL, arg1, arg2);
|
||||
}
|
||||
|
||||
static inline void spl_instantiate_arg_n(
|
||||
zend_class_entry *pce, zval *retval, uint32_t argc, zval *argv)
|
||||
{
|
||||
object_init_ex(retval, pce);
|
||||
zend_call_known_instance_method(pce->constructor, Z_OBJ_P(retval), NULL, argc, argv);
|
||||
}
|
||||
|
||||
#endif /* SPL_ENGINE_H */
|
|
@ -20,12 +20,12 @@
|
|||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "zend_interfaces.h"
|
||||
#include "zend_exceptions.h"
|
||||
|
||||
#include "php_spl.h"
|
||||
#include "spl_fixedarray_arginfo.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_fixedarray.h"
|
||||
#include "spl_exceptions.h"
|
||||
#include "spl_iterators.h"
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "zend_interfaces.h"
|
||||
#include "zend_exceptions.h"
|
||||
|
||||
#include "php_spl.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_iterators.h"
|
||||
#include "spl_heap.h"
|
||||
#include "spl_heap_arginfo.h"
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "php_spl.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_iterators.h"
|
||||
#include "spl_iterators_arginfo.h"
|
||||
#include "spl_directory.h"
|
||||
|
@ -539,7 +538,6 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
|
|||
|
||||
switch (rit_type) {
|
||||
case RIT_RecursiveTreeIterator: {
|
||||
zval caching_it_flags;
|
||||
zend_long user_caching_it_flags = CIT_CATCH_GET_CHILD;
|
||||
mode = RIT_SELF_FIRST;
|
||||
flags = RTIT_BYPASS_KEY;
|
||||
|
@ -558,10 +556,15 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
|
|||
Z_ADDREF_P(iterator);
|
||||
}
|
||||
|
||||
ZVAL_LONG(&caching_it_flags, user_caching_it_flags);
|
||||
spl_instantiate_arg_ex2(spl_ce_RecursiveCachingIterator, &caching_it, iterator, &caching_it_flags);
|
||||
zval_ptr_dtor(&caching_it_flags);
|
||||
zval_ptr_dtor(iterator);
|
||||
zval params[2];
|
||||
ZVAL_COPY_VALUE(¶ms[0], iterator);
|
||||
ZVAL_LONG(¶ms[1], user_caching_it_flags);
|
||||
zend_result is_initialized = object_init_with_constructor(&caching_it, spl_ce_RecursiveCachingIterator, 2, params, NULL);
|
||||
zval_ptr_dtor(¶ms[0]);
|
||||
if (is_initialized == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
iterator = &caching_it;
|
||||
break;
|
||||
}
|
||||
|
@ -1674,37 +1677,48 @@ PHP_METHOD(RecursiveFilterIterator, hasChildren)
|
|||
PHP_METHOD(RecursiveFilterIterator, getChildren)
|
||||
{
|
||||
spl_dual_it_object *intern;
|
||||
zval retval;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
|
||||
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval);
|
||||
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
|
||||
spl_instantiate_arg_ex1(Z_OBJCE_P(ZEND_THIS), return_value, &retval);
|
||||
zval childrens;
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &childrens);
|
||||
if (Z_TYPE(childrens) == IS_UNDEF) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 1, &childrens, NULL);
|
||||
zval_ptr_dtor(&childrens);
|
||||
if (is_initialized == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ Return the inner iterator's children contained in a RecursiveCallbackFilterIterator */
|
||||
PHP_METHOD(RecursiveCallbackFilterIterator, getChildren)
|
||||
{
|
||||
spl_dual_it_object *intern;
|
||||
zval retval;
|
||||
spl_dual_it_object *intern;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
|
||||
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval);
|
||||
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
|
||||
zval callable;
|
||||
zend_get_callable_zval_from_fcc(&intern->u.callback_filter, &callable);
|
||||
spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &retval, &callable);
|
||||
zval_ptr_dtor(&callable);
|
||||
zval params[2];
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", ¶ms[0]);
|
||||
if (Z_TYPE(params[0]) == IS_UNDEF) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* Get callable to pass to the constructor */
|
||||
zend_get_callable_zval_from_fcc(&intern->u.callback_filter, ¶ms[1]);
|
||||
|
||||
zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 2, params, NULL);
|
||||
zval_ptr_dtor(¶ms[0]);
|
||||
zval_ptr_dtor(¶ms[1]);
|
||||
if (is_initialized == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
} /* }}} */
|
||||
/* {{{ Create a ParentIterator from a RecursiveIterator */
|
||||
PHP_METHOD(ParentIterator, __construct)
|
||||
|
@ -1961,21 +1975,25 @@ PHP_METHOD(RecursiveRegexIterator, getChildren)
|
|||
SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
|
||||
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &retval);
|
||||
if (!EG(exception)) {
|
||||
zval args[5];
|
||||
|
||||
ZVAL_COPY(&args[0], &retval);
|
||||
ZVAL_STR_COPY(&args[1], intern->u.regex.regex);
|
||||
ZVAL_LONG(&args[2], intern->u.regex.mode);
|
||||
ZVAL_LONG(&args[3], intern->u.regex.flags);
|
||||
ZVAL_LONG(&args[4], intern->u.regex.preg_flags);
|
||||
|
||||
spl_instantiate_arg_n(Z_OBJCE_P(ZEND_THIS), return_value, 5, args);
|
||||
|
||||
zval_ptr_dtor(&args[0]);
|
||||
zval_ptr_dtor(&args[1]);
|
||||
if (EG(exception)) {
|
||||
zval_ptr_dtor(&retval);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
zval args[5];
|
||||
ZVAL_COPY_VALUE(&args[0], &retval);
|
||||
ZVAL_STR_COPY(&args[1], intern->u.regex.regex);
|
||||
ZVAL_LONG(&args[2], intern->u.regex.mode);
|
||||
ZVAL_LONG(&args[3], intern->u.regex.flags);
|
||||
ZVAL_LONG(&args[4], intern->u.regex.preg_flags);
|
||||
|
||||
zend_result is_initialized = object_init_with_constructor(return_value, Z_OBJCE_P(ZEND_THIS), 5, args, NULL);
|
||||
|
||||
zval_ptr_dtor(&args[0]);
|
||||
zval_ptr_dtor_str(&args[1]);
|
||||
if (is_initialized == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
} /* }}} */
|
||||
|
||||
PHP_METHOD(RecursiveRegexIterator, accept)
|
||||
|
@ -2246,7 +2264,7 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
|
|||
}
|
||||
/* Recursion ? */
|
||||
if (intern->dit_type == DIT_RecursiveCachingIterator) {
|
||||
zval retval, zchildren, zflags;
|
||||
zval retval;
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "haschildren", &retval);
|
||||
if (EG(exception)) {
|
||||
zval_ptr_dtor(&retval);
|
||||
|
@ -2256,28 +2274,39 @@ static inline void spl_caching_it_next(spl_dual_it_object *intern)
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
if (zend_is_true(&retval)) {
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &zchildren);
|
||||
bool has_children = zend_is_true(&retval);
|
||||
zval_ptr_dtor(&retval);
|
||||
|
||||
if (has_children) {
|
||||
zval args[2];
|
||||
|
||||
/* Store the children in the first constructor argument */
|
||||
zend_call_method_with_0_params(Z_OBJ(intern->inner.zobject), intern->inner.ce, NULL, "getchildren", &args[0]);
|
||||
if (EG(exception)) {
|
||||
zval_ptr_dtor(&zchildren);
|
||||
zval_ptr_dtor(&args[0]);
|
||||
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
|
||||
zend_clear_exception();
|
||||
} else {
|
||||
zval_ptr_dtor(&retval);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ZVAL_LONG(&zflags, intern->u.caching.flags & CIT_PUBLIC);
|
||||
spl_instantiate_arg_ex2(spl_ce_RecursiveCachingIterator, &intern->u.caching.zchildren, &zchildren, &zflags);
|
||||
zval_ptr_dtor(&zchildren);
|
||||
}
|
||||
}
|
||||
zval_ptr_dtor(&retval);
|
||||
if (EG(exception)) {
|
||||
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
|
||||
zend_clear_exception();
|
||||
} else {
|
||||
return;
|
||||
ZVAL_LONG(&args[1], intern->u.caching.flags & CIT_PUBLIC);
|
||||
|
||||
zend_result is_initialized = object_init_with_constructor(
|
||||
&intern->u.caching.zchildren,
|
||||
spl_ce_RecursiveCachingIterator,
|
||||
2,
|
||||
args,
|
||||
NULL
|
||||
);
|
||||
zval_ptr_dtor(&args[0]);
|
||||
if (is_initialized == FAILURE) {
|
||||
if (intern->u.caching.flags & CIT_CATCH_GET_CHILD) {
|
||||
zend_clear_exception();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "php_spl.h"
|
||||
#include "spl_functions.h"
|
||||
#include "spl_engine.h"
|
||||
#include "spl_observer.h"
|
||||
#include "spl_observer_arginfo.h"
|
||||
#include "spl_iterators.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue