xref: /PHP-8.0/ext/intl/locale/locale.c (revision 5d6e923d)
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    | http://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    | Author: Kirti Velankar <kirtig@yahoo-inc.com>                        |
12    +----------------------------------------------------------------------+
13 */
14 
15 #ifdef HAVE_CONFIG_H
16 #include "config.h"
17 #endif
18 
19 #include "locale_class.h"
20 #include "locale.h"
21 
22 #include <unicode/utypes.h>
23 #include <unicode/uloc.h>
24 #include <unicode/ustring.h>
25 
26 /* {{{ locale_register_constants
27  * Register constants common for the both (OO and procedural)
28  * APIs.
29  */
locale_register_constants(INIT_FUNC_ARGS)30 void locale_register_constants( INIT_FUNC_ARGS )
31 {
32 	if( !Locale_ce_ptr )
33 	{
34 		zend_error( E_ERROR, "Locale class not defined" );
35 		return;
36 	}
37 
38 	#define LOCALE_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
39 	#define LOCALE_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Locale_ce_ptr, ZEND_STRS( #x ) - 1, ULOC_##x );
40 	#define LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR(name, value) zend_declare_class_constant_string( Locale_ce_ptr, ZEND_STRS( name ) - 1, value );
41 
42 	LOCALE_EXPOSE_CLASS_CONST( ACTUAL_LOCALE );
43 	LOCALE_EXPOSE_CLASS_CONST( VALID_LOCALE );
44 
45 	zend_declare_class_constant_null(Locale_ce_ptr, ZEND_STRS("DEFAULT_LOCALE") - 1);
46 
47 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "LANG_TAG", LOC_LANG_TAG);
48 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "EXTLANG_TAG", LOC_EXTLANG_TAG);
49 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "SCRIPT_TAG", LOC_SCRIPT_TAG);
50 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "REGION_TAG", LOC_REGION_TAG);
51 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "VARIANT_TAG",LOC_VARIANT_TAG);
52 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "GRANDFATHERED_LANG_TAG",LOC_GRANDFATHERED_LANG_TAG);
53 	LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR( "PRIVATE_TAG",LOC_PRIVATE_TAG);
54 
55 	#undef LOCALE_EXPOSE_CUSTOM_CLASS_CONST_STR
56 	#undef LOCALE_EXPOSE_CLASS_CONST
57 	#undef LOCALE_EXPOSE_CONST
58 }
59 /* }}} */
60