1 : /*
2 : +----------------------------------------------------------------------+
3 : | PHP Version 6 |
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 :
19 : #ifdef HAVE_CONFIG_H
20 : # include "config.h"
21 : #endif
22 :
23 : #include "php.h"
24 : #include "php_ini.h"
25 : #include "ext/standard/info.h"
26 : #include "zend_interfaces.h"
27 :
28 : #include "php_spl.h"
29 : #include "spl_functions.h"
30 : #include "spl_engine.h"
31 :
32 : #include "spl_array.h"
33 :
34 : /* {{{ spl_instantiate */
35 : PHPAPI void spl_instantiate(zend_class_entry *pce, zval **object, int alloc TSRMLS_DC)
36 739 : {
37 739 : if (alloc) {
38 102 : ALLOC_ZVAL(*object);
39 : }
40 739 : object_init_ex(*object, pce);
41 739 : Z_SET_REFCOUNT_P((*object), 1);
42 739 : Z_SET_ISREF_PP(object); /* check if this can be hold always */
43 739 : }
44 : /* }}} */
45 :
46 : PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
47 33 : {
48 33 : switch(Z_TYPE_P(offset)) {
49 : case IS_STRING:
50 0 : ZEND_HANDLE_NUMERIC(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, idx);
51 0 : break;
52 : case IS_UNICODE:
53 14 : ZEND_HANDLE_U_NUMERIC(Z_USTRVAL_P(offset), Z_USTRLEN_P(offset)+1, idx);
54 4 : break;
55 : case IS_DOUBLE:
56 : case IS_RESOURCE:
57 : case IS_BOOL:
58 : case IS_LONG:
59 18 : if (Z_TYPE_P(offset) == IS_DOUBLE) {
60 0 : return (long)Z_DVAL_P(offset);
61 : } else {
62 18 : return Z_LVAL_P(offset);
63 : }
64 : }
65 5 : return -1;
66 : }
67 : /* }}} */
68 :
69 : /*
70 : * Local variables:
71 : * tab-width: 4
72 : * c-basic-offset: 4
73 : * End:
74 : * vim600: fdm=marker
75 : * vim: noet sw=4 ts=4
76 : */
|