locale.c 2.4 KB

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