spl_engine.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifdef HAVE_CONFIG_H
  19. # include "config.h"
  20. #endif
  21. #include "php.h"
  22. #include "php_ini.h"
  23. #include "ext/standard/info.h"
  24. #include "zend_interfaces.h"
  25. #include "php_spl.h"
  26. #include "spl_functions.h"
  27. #include "spl_engine.h"
  28. #include "spl_array.h"
  29. /* {{{ spl_instantiate */
  30. PHPAPI void spl_instantiate(zend_class_entry *pce, zval *object)
  31. {
  32. object_init_ex(object, pce);
  33. }
  34. /* }}} */
  35. PHPAPI zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */
  36. {
  37. zend_ulong idx;
  38. try_again:
  39. switch (Z_TYPE_P(offset)) {
  40. case IS_STRING:
  41. if (ZEND_HANDLE_NUMERIC(Z_STR_P(offset), idx)) {
  42. return idx;
  43. }
  44. break;
  45. case IS_DOUBLE:
  46. return (zend_long)Z_DVAL_P(offset);
  47. case IS_LONG:
  48. return Z_LVAL_P(offset);
  49. case IS_FALSE:
  50. return 0;
  51. case IS_TRUE:
  52. return 1;
  53. case IS_REFERENCE:
  54. offset = Z_REFVAL_P(offset);
  55. goto try_again;
  56. case IS_RESOURCE:
  57. return Z_RES_HANDLE_P(offset);
  58. }
  59. return -1;
  60. }
  61. /* }}} */
  62. /*
  63. * Local variables:
  64. * tab-width: 4
  65. * c-basic-offset: 4
  66. * End:
  67. * vim600: fdm=marker
  68. * vim: noet sw=4 ts=4
  69. */