spl_engine.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Marcus Boerger <helly@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef SPL_ENGINE_H
  19. #define SPL_ENGINE_H
  20. #include "php.h"
  21. #include "php_spl.h"
  22. #include "zend_interfaces.h"
  23. PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object);
  24. PHPAPI zend_long spl_offset_convert_to_long(zval *offset);
  25. /* {{{ spl_instantiate_arg_ex1 */
  26. static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval *retval, zval *arg1)
  27. {
  28. zend_function *func = pce->constructor;
  29. spl_instantiate(pce, retval);
  30. zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 1, arg1, NULL);
  31. return 0;
  32. }
  33. /* }}} */
  34. /* {{{ spl_instantiate_arg_ex2 */
  35. static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval *retval, zval *arg1, zval *arg2)
  36. {
  37. zend_function *func = pce->constructor;
  38. spl_instantiate(pce, retval);
  39. zend_call_method(retval, pce, &func, ZSTR_VAL(func->common.function_name), ZSTR_LEN(func->common.function_name), NULL, 2, arg1, arg2);
  40. return 0;
  41. }
  42. /* }}} */
  43. /* {{{ spl_instantiate_arg_n */
  44. static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval *retval, int argc, zval *argv)
  45. {
  46. zend_function *func = pce->constructor;
  47. zend_fcall_info fci;
  48. zend_fcall_info_cache fcc;
  49. zval dummy;
  50. spl_instantiate(pce, retval);
  51. fci.size = sizeof(zend_fcall_info);
  52. ZVAL_STR(&fci.function_name, func->common.function_name);
  53. fci.object = Z_OBJ_P(retval);
  54. fci.retval = &dummy;
  55. fci.param_count = argc;
  56. fci.params = argv;
  57. fci.no_separation = 1;
  58. fcc.function_handler = func;
  59. fcc.called_scope = pce;
  60. fcc.object = Z_OBJ_P(retval);
  61. zend_call_function(&fci, &fcc);
  62. }
  63. /* }}} */
  64. #endif /* SPL_ENGINE_H */
  65. /*
  66. * Local Variables:
  67. * c-basic-offset: 4
  68. * tab-width: 4
  69. * End:
  70. * vim600: fdm=marker
  71. * vim: noet sw=4 ts=4
  72. */