Back to index

php5  5.3.10
spl_engine.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Marcus Boerger <helly@php.net>                              |
00016    +----------------------------------------------------------------------+
00017  */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 # include "config.h"
00021 #endif
00022 
00023 #include "php.h"
00024 #include "php_ini.h"
00025 #include "ext/standard/info.h"
00026 #include "zend_interfaces.h"
00027 
00028 #include "php_spl.h"
00029 #include "spl_functions.h"
00030 #include "spl_engine.h"
00031 
00032 #include "spl_array.h"
00033 
00034 /* {{{ spl_instantiate */
00035 PHPAPI void spl_instantiate(zend_class_entry *pce, zval **object, int alloc TSRMLS_DC)
00036 {
00037        if (alloc) {
00038               ALLOC_ZVAL(*object);
00039        }
00040        object_init_ex(*object, pce);
00041        Z_SET_REFCOUNT_PP(object, 1);
00042        Z_SET_ISREF_PP(object); /* check if this can be hold always */
00043 }
00044 /* }}} */
00045 
00046 PHPAPI long spl_offset_convert_to_long(zval *offset TSRMLS_DC) /* {{{ */
00047 {
00048        switch(Z_TYPE_P(offset)) {
00049        case IS_STRING:
00050               ZEND_HANDLE_NUMERIC(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, idx);
00051               break;
00052        case IS_DOUBLE:
00053        case IS_RESOURCE:
00054        case IS_BOOL:
00055        case IS_LONG:
00056               if (Z_TYPE_P(offset) == IS_DOUBLE) {
00057                      return (long)Z_DVAL_P(offset);
00058               } else {
00059                      return Z_LVAL_P(offset);
00060               }
00061        }
00062        return -1;
00063 } 
00064 /* }}} */
00065 
00066 /*
00067  * Local variables:
00068  * tab-width: 4
00069  * c-basic-offset: 4
00070  * End:
00071  * vim600: fdm=marker
00072  * vim: noet sw=4 ts=4
00073  */