php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
dateformat_class.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | This source file is subject to version 3.01 of the PHP license, |
4 | that is bundled with this package in the file LICENSE, and is |
5 | available through the world-wide-web at the following url: |
6 | https://www.php.net/license/3_01.txt |
7 | If you did not receive a copy of the PHP license and are unable to |
8 | obtain it through the world-wide-web, please send a note to |
9 | license@php.net so we can mail you a copy immediately. |
10 +----------------------------------------------------------------------+
11 | Authors: Kirti Velankar <kirtig@yahoo-inc.com> |
12 +----------------------------------------------------------------------+
13*/
14#include <unicode/unum.h>
15
16#include "dateformat_class.h"
17#include "php_intl.h"
18#include "dateformat_data.h"
19#include "dateformat.h"
20#include "dateformat_arginfo.h"
21
22#include <zend_exceptions.h>
23
25static zend_object_handlers IntlDateFormatter_handlers;
26
27/*
28 * Auxiliary functions needed by objects of 'IntlDateFormatter' class
29 */
30
31/* {{{ IntlDateFormatter_objects_free */
33{
34 IntlDateFormatter_object* dfo = php_intl_dateformatter_fetch_object(object);
35
36 zend_object_std_dtor( &dfo->zo );
37
38 if (dfo->requested_locale) {
39 efree( dfo->requested_locale );
40 }
41
43}
44/* }}} */
45
46/* {{{ IntlDateFormatter_object_create */
48{
50
51 intern = zend_object_alloc(sizeof(IntlDateFormatter_object), ce);
53 zend_object_std_init( &intern->zo, ce );
54 object_properties_init(&intern->zo, ce);
55 intern->date_type = 0;
56 intern->time_type = 0;
57 intern->calendar = -1;
58 intern->requested_locale = NULL;
59
60 return &intern->zo;
61}
62/* }}} */
63
64/* {{{ IntlDateFormatter_object_clone */
66{
67 IntlDateFormatter_object *dfo = php_intl_dateformatter_fetch_object(object);
68 zend_object *new_obj = IntlDateFormatter_ce_ptr->create_object(object->ce);
69 IntlDateFormatter_object *new_dfo = php_intl_dateformatter_fetch_object(new_obj);
70
71 /* clone standard parts */
72 zend_objects_clone_members(&new_dfo->zo, &dfo->zo);
73
74 /* clone formatter object */
75 if (DATE_FORMAT_OBJECT(dfo) != NULL) {
76 UErrorCode error = U_ZERO_ERROR;
77 DATE_FORMAT_OBJECT(new_dfo) = udat_clone(DATE_FORMAT_OBJECT(dfo), &error);
78
79 if (U_FAILURE(error)) {
80 zend_throw_error(NULL, "Failed to clone IntlDateFormatter");
81 }
82 } else {
83 zend_throw_error(NULL, "Cannot clone uninitialized IntlDateFormatter");
84 }
85 return new_obj;
86}
87/* }}} */
88
89/*
90 * 'IntlDateFormatter' class registration structures & functions
91 */
92
93/* {{{ dateformat_register_class
94 * Initialize 'IntlDateFormatter' class
95 */
97{
98 /* Create and register 'IntlDateFormatter' class. */
99 IntlDateFormatter_ce_ptr = register_class_IntlDateFormatter();
101 IntlDateFormatter_ce_ptr->default_object_handlers = &IntlDateFormatter_handlers;
102
103 memcpy(&IntlDateFormatter_handlers, &std_object_handlers,
104 sizeof IntlDateFormatter_handlers);
105 IntlDateFormatter_handlers.offset = XtOffsetOf(IntlDateFormatter_object, zo);
106 IntlDateFormatter_handlers.clone_obj = IntlDateFormatter_object_clone;
107 IntlDateFormatter_handlers.free_obj = IntlDateFormatter_object_free;
108}
109/* }}} */
const U_ZERO_ERROR
void dateformat_register_IntlDateFormatter_class(void)
zend_class_entry * IntlDateFormatter_ce_ptr
zend_object * IntlDateFormatter_object_create(zend_class_entry *ce)
void IntlDateFormatter_object_free(zend_object *object)
zend_object * IntlDateFormatter_object_clone(zend_object *object)
#define DATE_FORMAT_OBJECT(dfo)
void dateformat_data_init(dateformat_data *datef_data)
void dateformat_data_free(dateformat_data *datef_data)
error($message)
Definition ext_skel.php:22
memcpy(ptr1, ptr2, size)
#define NULL
Definition gdcache.h:45
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type)
Definition zend_API.c:1688
#define efree(ptr)
Definition zend_alloc.h:155
ZEND_API const zend_object_handlers std_object_handlers
ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, zend_object *old_object)
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce)
ZEND_API void zend_object_std_dtor(zend_object *object)
#define XtOffsetOf(s_type, field)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
struct _zend_object_handlers zend_object_handlers
Definition zend_types.h:88
object