1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 7 |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | http://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
14 | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
15 +----------------------------------------------------------------------+
16 */
17
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include "collator_class.h"
23 #include "collator.h"
24
25 #include <unicode/utypes.h>
26 #include <unicode/ucol.h>
27 #include <unicode/ustring.h>
28
29 /* {{{ collator_register_constants
30 * Register constants common for the both (OO and procedural)
31 * APIs.
32 */
collator_register_constants(INIT_FUNC_ARGS)33 void collator_register_constants( INIT_FUNC_ARGS )
34 {
35 if( !Collator_ce_ptr )
36 {
37 zend_error( E_ERROR, "Collator class not defined" );
38 return;
39 }
40
41 #define COLLATOR_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
42 #define COLLATOR_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( #x ) - 1, UCOL_##x );
43 #define COLLATOR_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Collator_ce_ptr, ZEND_STRS( name ) - 1, value );
44
45 /* UColAttributeValue constants */
46 COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "DEFAULT_VALUE", UCOL_DEFAULT );
47
48 COLLATOR_EXPOSE_CLASS_CONST( PRIMARY );
49 COLLATOR_EXPOSE_CLASS_CONST( SECONDARY );
50 COLLATOR_EXPOSE_CLASS_CONST( TERTIARY );
51 COLLATOR_EXPOSE_CLASS_CONST( DEFAULT_STRENGTH );
52 COLLATOR_EXPOSE_CLASS_CONST( QUATERNARY );
53 COLLATOR_EXPOSE_CLASS_CONST( IDENTICAL );
54
55 COLLATOR_EXPOSE_CLASS_CONST( OFF );
56 COLLATOR_EXPOSE_CLASS_CONST( ON );
57
58 COLLATOR_EXPOSE_CLASS_CONST( SHIFTED );
59 COLLATOR_EXPOSE_CLASS_CONST( NON_IGNORABLE );
60
61 COLLATOR_EXPOSE_CLASS_CONST( LOWER_FIRST );
62 COLLATOR_EXPOSE_CLASS_CONST( UPPER_FIRST );
63
64 /* UColAttribute constants */
65 COLLATOR_EXPOSE_CLASS_CONST( FRENCH_COLLATION );
66 COLLATOR_EXPOSE_CLASS_CONST( ALTERNATE_HANDLING );
67 COLLATOR_EXPOSE_CLASS_CONST( CASE_FIRST );
68 COLLATOR_EXPOSE_CLASS_CONST( CASE_LEVEL );
69 COLLATOR_EXPOSE_CLASS_CONST( NORMALIZATION_MODE );
70 COLLATOR_EXPOSE_CLASS_CONST( STRENGTH );
71 COLLATOR_EXPOSE_CLASS_CONST( HIRAGANA_QUATERNARY_MODE );
72 COLLATOR_EXPOSE_CLASS_CONST( NUMERIC_COLLATION );
73
74 /* ULocDataLocaleType constants */
75 COLLATOR_EXPOSE_CONST( ULOC_ACTUAL_LOCALE );
76 COLLATOR_EXPOSE_CONST( ULOC_VALID_LOCALE );
77
78 /* sort flags */
79 COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_REGULAR", COLLATOR_SORT_REGULAR );
80 COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_STRING", COLLATOR_SORT_STRING );
81 COLLATOR_EXPOSE_CUSTOM_CLASS_CONST( "SORT_NUMERIC", COLLATOR_SORT_NUMERIC );
82
83 #undef COLLATOR_EXPOSE_CUSTOM_CLASS_CONST
84 #undef COLLATOR_EXPOSE_CLASS_CONST
85 #undef COLLATOR_EXPOSE_CONST
86 }
87 /* }}} */
88
89 /*
90 * Local variables:
91 * tab-width: 4
92 * c-basic-offset: 4
93 * End:
94 * vim600: noet sw=4 ts=4 fdm=marker
95 * vim<600: noet sw=4 ts=4
96 */
97