spl_engine.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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. /* $Id$ */
  19. #ifndef SPL_ENGINE_H
  20. #define SPL_ENGINE_H
  21. #include "php.h"
  22. #include "php_spl.h"
  23. #include "zend_interfaces.h"
  24. PHPAPI void spl_instantiate(zend_class_entry *pce, zval **object, int alloc TSRMLS_DC);
  25. PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC);
  26. /* {{{ spl_instantiate_arg_ex1 */
  27. static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval **retval, int alloc, zval *arg1 TSRMLS_DC)
  28. {
  29. spl_instantiate(pce, retval, alloc TSRMLS_CC);
  30. zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), NULL, 1, arg1, NULL TSRMLS_CC);
  31. return 0;
  32. }
  33. /* }}} */
  34. /* {{{ spl_instantiate_arg_ex2 */
  35. static inline int spl_instantiate_arg_ex2(zend_class_entry *pce, zval **retval, int alloc, zval *arg1, zval *arg2 TSRMLS_DC)
  36. {
  37. spl_instantiate(pce, retval, alloc TSRMLS_CC);
  38. zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), NULL, 2, arg1, arg2 TSRMLS_CC);
  39. return 0;
  40. }
  41. /* }}} */
  42. /* {{{ spl_instantiate_arg_n */
  43. static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval **retval, int argc, zval ***argv TSRMLS_DC)
  44. {
  45. zend_function *func = pce->constructor;
  46. zend_fcall_info fci;
  47. zend_fcall_info_cache fcc;
  48. zval *dummy;
  49. zval z_name;
  50. spl_instantiate(pce, retval, 0 TSRMLS_CC);
  51. ZVAL_STRING(&z_name, func->common.function_name, 0);
  52. fci.size = sizeof(zend_fcall_info);
  53. fci.function_table = &pce->function_table;
  54. fci.function_name = &z_name;
  55. fci.object_ptr = *retval;
  56. fci.symbol_table = NULL;
  57. fci.retval_ptr_ptr = &dummy;
  58. fci.param_count = argc;
  59. fci.params = argv;
  60. fci.no_separation = 1;
  61. fcc.initialized = 1;
  62. fcc.function_handler = func;
  63. fcc.calling_scope = EG(scope);
  64. fcc.called_scope = pce;
  65. fcc.object_ptr = *retval;
  66. zend_call_function(&fci, &fcc TSRMLS_CC);
  67. zval_ptr_dtor(&dummy);
  68. }
  69. /* }}} */
  70. #endif /* SPL_ENGINE_H */
  71. /*
  72. * Local Variables:
  73. * c-basic-offset: 4
  74. * tab-width: 4
  75. * End:
  76. * vim600: fdm=marker
  77. * vim: noet sw=4 ts=4
  78. */