php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
msgformat_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: Stanislav Malyshev <stas@zend.com> |
12 +----------------------------------------------------------------------+
13 */
14
15#include <unicode/unum.h>
16
17#include "msgformat_class.h"
18#include "php_intl.h"
19#include "msgformat_data.h"
20#include "msgformat_arginfo.h"
21
22#include <zend_exceptions.h>
23
25static zend_object_handlers MessageFormatter_handlers;
26
27/*
28 * Auxiliary functions needed by objects of 'MessageFormatter' class
29 */
30
31/* {{{ MessageFormatter_objects_free */
33{
34 MessageFormatter_object* mfo = php_intl_messageformatter_fetch_object(object);
35
36 zend_object_std_dtor( &mfo->zo );
37
39}
40/* }}} */
41
42/* {{{ MessageFormatter_object_create */
44{
46
47 intern = zend_object_alloc(sizeof(MessageFormatter_object), ce);
48 msgformat_data_init( &intern->mf_data );
49 zend_object_std_init( &intern->zo, ce );
50 object_properties_init(&intern->zo, ce);
51
52 return &intern->zo;
53}
54/* }}} */
55
56/* {{{ MessageFormatter_object_clone */
58{
59 MessageFormatter_object *mfo = php_intl_messageformatter_fetch_object(object);
60 zend_object *new_obj = MessageFormatter_ce_ptr->create_object(object->ce);
61 MessageFormatter_object *new_mfo = php_intl_messageformatter_fetch_object(new_obj);
62
63 /* clone standard parts */
64 zend_objects_clone_members(&new_mfo->zo, &mfo->zo);
65
66 /* clone formatter object */
67 if (MSG_FORMAT_OBJECT(mfo) != NULL) {
68 UErrorCode error = U_ZERO_ERROR;
69 MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), &error);
70
71 if (U_FAILURE(error)) {
72 zend_throw_error(NULL, "Failed to clone MessageFormatter");
73 }
74 } else {
75 zend_throw_error(NULL, "Cannot clone uninitialized MessageFormatter");
76 }
77 return new_obj;
78}
79/* }}} */
80
81/*
82 * 'MessageFormatter' class registration structures & functions
83 */
84
85/* {{{ msgformat_register_class
86 * Initialize 'MessageFormatter' class
87 */
89{
90 /* Create and register 'MessageFormatter' class. */
91 MessageFormatter_ce_ptr = register_class_MessageFormatter();
93 MessageFormatter_ce_ptr->default_object_handlers = &MessageFormatter_handlers;
94
95 memcpy(&MessageFormatter_handlers, &std_object_handlers,
96 sizeof MessageFormatter_handlers);
97 MessageFormatter_handlers.offset = XtOffsetOf(MessageFormatter_object, zo);
98 MessageFormatter_handlers.clone_obj = MessageFormatter_object_clone;
99 MessageFormatter_handlers.free_obj = MessageFormatter_object_free;
100}
101/* }}} */
const U_ZERO_ERROR
error($message)
Definition ext_skel.php:22
memcpy(ptr1, ptr2, size)
#define NULL
Definition gdcache.h:45
zend_class_entry * MessageFormatter_ce_ptr
void msgformat_register_class(void)
void MessageFormatter_object_free(zend_object *object)
zend_object * MessageFormatter_object_create(zend_class_entry *ce)
zend_object * MessageFormatter_object_clone(zend_object *object)
#define MSG_FORMAT_OBJECT(mfo)
void msgformat_data_free(msgformat_data *mf_data)
void msgformat_data_init(msgformat_data *mf_data)
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
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