|
| 1 | +/* |
| 2 | + +----------------------------------------------------------------------+ |
| 3 | + | Copyright © The PHP Group and Contributors. | |
| 4 | + +----------------------------------------------------------------------+ |
| 5 | + | This source file is subject to the Modified BSD License that is | |
| 6 | + | bundled with this package in the file LICENSE, and is available | |
| 7 | + | through the World Wide Web at <https://www.php.net/license/>. | |
| 8 | + | | |
| 9 | + | SPDX-License-Identifier: BSD-3-Clause | |
| 10 | + +----------------------------------------------------------------------+ |
| 11 | + | Authors: Derick Rethans <derick@derickrethans.nl> | |
| 12 | + | Tim Düsterhus <timwolla@php.net> | |
| 13 | + +----------------------------------------------------------------------+ |
| 14 | + */ |
| 15 | + |
| 16 | +#include "php.h" |
| 17 | +#include "Zend/zend_exceptions.h" |
| 18 | + |
| 19 | +#include "php_date_time.h" |
| 20 | +#include "php_date_time_arginfo.h" |
| 21 | + |
| 22 | +zend_class_entry *php_date_ce_time_duration; |
| 23 | +zend_class_entry *php_date_ce_time_timeexception; |
| 24 | + |
| 25 | +static zend_object_handlers php_date_time_duration_object_handlers; |
| 26 | + |
| 27 | +static zend_object *php_date_time_duration_object_create(zend_class_entry *ce) |
| 28 | +{ |
| 29 | + php_date_time_duration *obj = zend_object_alloc(sizeof(*obj), ce); |
| 30 | + |
| 31 | + zend_object_std_init(&obj->std, ce); |
| 32 | + object_properties_init(&obj->std, ce); |
| 33 | + |
| 34 | + timelib_duration_ctor_static(&obj->duration, 0,0, false); |
| 35 | + |
| 36 | + return &obj->std; |
| 37 | +} |
| 38 | + |
| 39 | +PHP_MINIT_FUNCTION(date_time) |
| 40 | +{ |
| 41 | + php_date_ce_time_timeexception = register_class_Time_TimeException(zend_ce_exception); |
| 42 | + |
| 43 | + memcpy(&php_date_time_duration_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); |
| 44 | + php_date_time_duration_object_handlers.offset = offsetof(php_date_time_duration, std); |
| 45 | + php_date_ce_time_duration = register_class_Time_Duration(); |
| 46 | + php_date_ce_time_duration->create_object = php_date_time_duration_object_create; |
| 47 | + php_date_ce_time_duration->default_object_handlers = &php_date_time_duration_object_handlers; |
| 48 | + |
| 49 | + return SUCCESS; |
| 50 | +} |
0 commit comments