xref: /PHP-7.0/ext/intl/locale/locale_class.c (revision 7dc6b04f)
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: Kirti Velankar <kirtig@yahoo-inc.com>                       |
14    +----------------------------------------------------------------------+
15 */
16 
17 /* $Id$ */
18 
19 #include <unicode/uloc.h>
20 #include "php_intl.h"
21 #include "intl_error.h"
22 #include "locale_class.h"
23 #include "locale_methods.h"
24 #include "locale.h"
25 
26 zend_class_entry *Locale_ce_ptr = NULL;
27 
28 /*
29  * 'Locale' class registration structures & functions
30  */
31 
32 /* {{{ Locale methods arguments info */
33 /*
34  *  NOTE: when modifying 'locale_XX_args' do not forget to modify
35  *        approptiate 'locale_XX_args' for the procedural API!
36  */
37 
38 ZEND_BEGIN_ARG_INFO_EX( locale_0_args, 0, 0, 0 )
39 ZEND_END_ARG_INFO()
40 
41 ZEND_BEGIN_ARG_INFO_EX( locale_arg_locale, 0, 0, 1 )
42 	ZEND_ARG_INFO( 0, locale )
43 ZEND_END_ARG_INFO()
44 
45 ZEND_BEGIN_ARG_INFO_EX( locale_accept_from_http_args, 0, 0, 1 )
46 	ZEND_ARG_INFO( 0, header )
47 ZEND_END_ARG_INFO()
48 
49 ZEND_BEGIN_ARG_INFO_EX( locale_compose_args, 0, 0, 1 )
50 	ZEND_ARG_INFO( 0, subtags )
51 ZEND_END_ARG_INFO()
52 
53 ZEND_BEGIN_ARG_INFO_EX( locale_2_args, 0, 0, 1 )
54 	ZEND_ARG_INFO( 0, locale )
55 	ZEND_ARG_INFO( 0, in_locale )
56 ZEND_END_ARG_INFO()
57 
58 ZEND_BEGIN_ARG_INFO_EX( locale_filter_matches_args, 0, 0, 2 )
59         ZEND_ARG_INFO( 0, langtag )
60         ZEND_ARG_INFO( 0, locale )
61         ZEND_ARG_INFO( 0, canonicalize )
62 ZEND_END_ARG_INFO()
63 
64 ZEND_BEGIN_ARG_INFO_EX( locale_lookup_args, 0, 0, 2 )
65         ZEND_ARG_INFO( 0, langtag )
66         ZEND_ARG_INFO( 0, locale )
67         ZEND_ARG_INFO( 0, canonicalize )
68         ZEND_ARG_INFO( 0, default )
69 ZEND_END_ARG_INFO()
70 
71 /* }}} */
72 
73 /* {{{ Locale_class_functions
74  * Every 'Locale' class method has an entry in this table
75  */
76 
77 zend_function_entry Locale_class_functions[] = {
78 	ZEND_FENTRY( getDefault, zif_locale_get_default , locale_0_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC  )
79 	ZEND_FENTRY( setDefault, zif_locale_set_default , locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
80 	ZEND_FENTRY( getPrimaryLanguage, ZEND_FN( locale_get_primary_language ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
81 	ZEND_FENTRY( getScript, ZEND_FN( locale_get_script ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
82 	ZEND_FENTRY( getRegion, ZEND_FN( locale_get_region ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
83 	ZEND_FENTRY( getKeywords, ZEND_FN( locale_get_keywords ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
84 	ZEND_FENTRY( getDisplayScript, ZEND_FN( locale_get_display_script ), locale_2_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
85 	ZEND_FENTRY( getDisplayRegion, ZEND_FN( locale_get_display_region ), locale_2_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
86 	ZEND_FENTRY( getDisplayName, ZEND_FN( locale_get_display_name ), locale_2_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
87 	ZEND_FENTRY( getDisplayLanguage, ZEND_FN( locale_get_display_language ), locale_2_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
88 	ZEND_FENTRY( getDisplayVariant, ZEND_FN( locale_get_display_variant ), locale_2_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
89 	ZEND_FENTRY( composeLocale, ZEND_FN( locale_compose ), locale_compose_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
90 	ZEND_FENTRY( parseLocale, ZEND_FN( locale_parse ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
91 	ZEND_FENTRY( getAllVariants, ZEND_FN( locale_get_all_variants ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
92 	ZEND_FENTRY( filterMatches, ZEND_FN( locale_filter_matches ), locale_filter_matches_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
93 	ZEND_FENTRY( lookup, ZEND_FN( locale_lookup ), locale_lookup_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
94 	ZEND_FENTRY( canonicalize, ZEND_FN( locale_canonicalize ), locale_arg_locale , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
95 	ZEND_FENTRY( acceptFromHttp, ZEND_FN( locale_accept_from_http ), locale_accept_from_http_args , ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
96 	PHP_FE_END
97 };
98 /* }}} */
99 
100 /* {{{ locale_register_Locale_class
101  * Initialize 'Locale' class
102  */
locale_register_Locale_class(void)103 void locale_register_Locale_class( void )
104 {
105 	zend_class_entry ce;
106 
107 	/* Create and register 'Locale' class. */
108 	INIT_CLASS_ENTRY( ce, "Locale", Locale_class_functions );
109 	ce.create_object = NULL;
110 	Locale_ce_ptr = zend_register_internal_class( &ce );
111 
112 	/* Declare 'Locale' class properties. */
113 	if( !Locale_ce_ptr )
114 	{
115 		zend_error( E_ERROR,
116 			"Locale: Failed to register Locale class.");
117 		return;
118 	}
119 }
120 /* }}} */
121 
122 /*
123  * Local variables:
124  * tab-width: 4
125  * c-basic-offset: 4
126  * End:
127  * vim600: noet sw=4 ts=4 fdm=marker
128  * vim<600: noet sw=4 ts=4
129  */
130