- Notifications
You must be signed in to change notification settings - Fork 7.8k
/
Copy pathmsgformat_class.c
101 lines (83 loc) · 3.37 KB
/
msgformat_class.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Stanislav Malyshev <stas@zend.com> |
+----------------------------------------------------------------------+
*/
#include<unicode/unum.h>
#include"msgformat_class.h"
#include"php_intl.h"
#include"msgformat_data.h"
#include"msgformat_arginfo.h"
#include<zend_exceptions.h>
zend_class_entry*MessageFormatter_ce_ptr=NULL;
staticzend_object_handlersMessageFormatter_handlers;
/*
* Auxiliary functions needed by objects of 'MessageFormatter' class
*/
/* {{{ MessageFormatter_objects_free */
voidMessageFormatter_object_free( zend_object*object )
{
MessageFormatter_object*mfo=php_intl_messageformatter_fetch_object(object);
zend_object_std_dtor( &mfo->zo );
msgformat_data_free( &mfo->mf_data );
}
/* }}} */
/* {{{ MessageFormatter_object_create */
zend_object*MessageFormatter_object_create(zend_class_entry*ce)
{
MessageFormatter_object*intern;
intern=zend_object_alloc(sizeof(MessageFormatter_object), ce);
msgformat_data_init( &intern->mf_data );
zend_object_std_init( &intern->zo, ce );
object_properties_init(&intern->zo, ce);
return&intern->zo;
}
/* }}} */
/* {{{ MessageFormatter_object_clone */
zend_object*MessageFormatter_object_clone(zend_object*object)
{
MessageFormatter_object*mfo=php_intl_messageformatter_fetch_object(object);
zend_object*new_obj=MessageFormatter_ce_ptr->create_object(object->ce);
MessageFormatter_object*new_mfo=php_intl_messageformatter_fetch_object(new_obj);
/* clone standard parts */
zend_objects_clone_members(&new_mfo->zo, &mfo->zo);
/* clone formatter object */
if (MSG_FORMAT_OBJECT(mfo) !=NULL) {
UErrorCodeerror=U_ZERO_ERROR;
MSG_FORMAT_OBJECT(new_mfo) =umsg_clone(MSG_FORMAT_OBJECT(mfo), &error);
if (U_FAILURE(error)) {
zend_throw_error(NULL, "Failed to clone MessageFormatter");
}
} else {
zend_throw_error(NULL, "Cannot clone uninitialized MessageFormatter");
}
returnnew_obj;
}
/* }}} */
/*
* 'MessageFormatter' class registration structures & functions
*/
/* {{{ msgformat_register_class
* Initialize 'MessageFormatter' class
*/
voidmsgformat_register_class( void )
{
/* Create and register 'MessageFormatter' class. */
MessageFormatter_ce_ptr=register_class_MessageFormatter();
MessageFormatter_ce_ptr->create_object=MessageFormatter_object_create;
MessageFormatter_ce_ptr->default_object_handlers=&MessageFormatter_handlers;
memcpy(&MessageFormatter_handlers, &std_object_handlers,
sizeofMessageFormatter_handlers);
MessageFormatter_handlers.offset=XtOffsetOf(MessageFormatter_object, zo);
MessageFormatter_handlers.clone_obj=MessageFormatter_object_clone;
MessageFormatter_handlers.free_obj=MessageFormatter_object_free;
}
/* }}} */