You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.2 KiB

23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
23 years ago
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2009 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, int alloc TSRMLS_DC)
  31. {
  32. if (alloc) {
  33. ALLOC_ZVAL(*object);
  34. }
  35. object_init_ex(*object, pce);
  36. Z_SET_REFCOUNT_PP(object, 1);
  37. Z_SET_ISREF_PP(object); /* check if this can be hold always */
  38. }
  39. /* }}} */
  40. PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
  41. {
  42. switch(Z_TYPE_P(offset)) {
  43. case IS_STRING:
  44. ZEND_HANDLE_NUMERIC(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, idx);
  45. break;
  46. case IS_DOUBLE:
  47. case IS_RESOURCE:
  48. case IS_BOOL:
  49. case IS_LONG:
  50. if (Z_TYPE_P(offset) == IS_DOUBLE) {
  51. return (long)Z_DVAL_P(offset);
  52. } else {
  53. return Z_LVAL_P(offset);
  54. }
  55. }
  56. return -1;
  57. }
  58. /* }}} */
  59. /*
  60. * Local variables:
  61. * tab-width: 4
  62. * c-basic-offset: 4
  63. * End:
  64. * vim600: fdm=marker
  65. * vim: noet sw=4 ts=4
  66. */