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: Ed Batutis <ed@batutis.com>                                 |
14    +----------------------------------------------------------------------+
15  */
16 
17 #include "normalizer_class.h"
18 #include "php_intl.h"
19 #include "normalizer_normalize.h"
20 #include "intl_error.h"
21 
22 #include <unicode/unorm.h>
23 
24 zend_class_entry *Normalizer_ce_ptr = NULL;
25 
26 /*
27  * 'Normalizer' class registration structures & functions
28  */
29 
30 /* {{{ Normalizer methods arguments info */
31 
32 ZEND_BEGIN_ARG_INFO_EX( normalizer_args, 0, 0, 1 )
33 	ZEND_ARG_INFO( 0, input )
34 	ZEND_ARG_INFO( 0, form )
35 ZEND_END_ARG_INFO()
36 
37 #if U_ICU_VERSION_MAJOR_NUM >= 56
38 ZEND_BEGIN_ARG_INFO_EX( decomposition_args, 0, 0, 1 )
39 	ZEND_ARG_INFO( 0, input )
40 ZEND_END_ARG_INFO();
41 #endif
42 
43 /* }}} */
44 
45 /* {{{ Normalizer_class_functions
46  * Every 'Normalizer' class method has an entry in this table
47  */
48 
49 static const zend_function_entry Normalizer_class_functions[] = {
50 	ZEND_FENTRY( normalize, ZEND_FN( normalizer_normalize ), normalizer_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
51 	ZEND_FENTRY( isNormalized, ZEND_FN( normalizer_is_normalized ), normalizer_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
52 #if U_ICU_VERSION_MAJOR_NUM >= 56
53 	ZEND_FENTRY( getRawDecomposition, ZEND_FN( normalizer_get_raw_decomposition ), decomposition_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC )
54 #endif
55 	PHP_FE_END
56 };
57 /* }}} */
58 
59 /* {{{ normalizer_register_Normalizer_class
60  * Initialize 'Normalizer' class
61  */
normalizer_register_Normalizer_class(void)62 void normalizer_register_Normalizer_class( void )
63 {
64 	zend_class_entry ce;
65 
66 	/* Create and register 'Normalizer' class. */
67 	INIT_CLASS_ENTRY( ce, "Normalizer", Normalizer_class_functions );
68 	ce.create_object = NULL;
69 	Normalizer_ce_ptr = zend_register_internal_class( &ce );
70 
71 	/* Declare 'Normalizer' class properties. */
72 	if( !Normalizer_ce_ptr )
73 	{
74 		zend_error( E_ERROR,
75 			"Normalizer: attempt to create properties "
76 			"on a non-registered class." );
77 		return;
78 	}
79 }
80 /* }}} */
81