Declare ext/intl constants in stubs - part 5 (#9267)

This commit is contained in:
Máté Kocsis 2022-08-08 12:00:10 +02:00 committed by GitHub
parent c1da9e7964
commit 614e9ec804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 119 additions and 69 deletions

View File

@ -27,7 +27,6 @@ if test "$PHP_INTL" != "no"; then
formatter/formatter_data.c \
formatter/formatter_format.c \
formatter/formatter_parse.c \
normalizer/normalizer.c \
normalizer/normalizer_class.c \
normalizer/normalizer_normalize.c \
locale/locale.c \

View File

@ -53,7 +53,6 @@ if (PHP_INTL != "no") {
grapheme_string.c grapheme_util.c \
", "intl");
ADD_SOURCES(configure_module_dirname + "/normalizer", "\
normalizer.c \
normalizer_class.c \
normalizer_normalize.c \
", "intl");

View File

@ -1,60 +0,0 @@
/*
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Ed Batutis <ed@batutis.com> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "normalizer_class.h"
#include "normalizer.h"
#include <unicode/utypes.h>
#include <unicode/unorm.h>
#include <unicode/ustring.h>
/* {{{ normalizer_register_constants
* Register constants common for the both (OO and procedural)
* APIs.
*/
void normalizer_register_constants( INIT_FUNC_ARGS )
{
if( !Normalizer_ce_ptr )
{
zend_error( E_ERROR, "Normalizer class not defined" );
return;
}
#define NORMALIZER_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
#define NORMALIZER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( #x ) - 1, NORMALIZER_##x );
#define NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( name ) - 1, value );
/* Normalization form constants */
NORMALIZER_EXPOSE_CLASS_CONST( FORM_D );
NORMALIZER_EXPOSE_CLASS_CONST( NFD );
NORMALIZER_EXPOSE_CLASS_CONST( FORM_KD );
NORMALIZER_EXPOSE_CLASS_CONST( NFKD );
NORMALIZER_EXPOSE_CLASS_CONST( FORM_C );
NORMALIZER_EXPOSE_CLASS_CONST( NFC );
NORMALIZER_EXPOSE_CLASS_CONST( FORM_KC );
NORMALIZER_EXPOSE_CLASS_CONST( NFKC );
#if U_ICU_VERSION_MAJOR_NUM >= 56
NORMALIZER_EXPOSE_CLASS_CONST( FORM_KC_CF );
NORMALIZER_EXPOSE_CLASS_CONST( NFKC_CF );
#endif
#undef NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST
#undef NORMALIZER_EXPOSE_CLASS_CONST
#undef NORMALIZER_EXPOSE_CONST
}
/* }}} */

View File

@ -45,6 +45,4 @@
#define NORMALIZER_DEFAULT NORMALIZER_FORM_C
#endif
void normalizer_register_constants( INIT_FUNC_ARGS );
#endif // NORMALIZER_NORMALIZER_H

View File

@ -4,6 +4,59 @@
class Normalizer
{
/**
* @var int
* @cvalue NORMALIZER_FORM_D
*/
public const FORM_D = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_NFD
*/
public const NFD = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_FORM_KD
*/
public const FORM_KD = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_NFKD
*/
public const NFKD = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_FORM_C
*/
public const FORM_C = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_NFC
*/
public const NFC = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_FORM_KC
*/
public const FORM_KC = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_NFKC
*/
public const NFKC = UNKNOWN;
#if U_ICU_VERSION_MAJOR_NUM >= 56
/**
* @var int
* @cvalue NORMALIZER_FORM_KC_CF
*/
public const FORM_KC_CF = UNKNOWN;
/**
* @var int
* @cvalue NORMALIZER_NFKC_CF
*/
public const NFKC_CF = UNKNOWN;
#endif
/**
* @tentative-return-type
* @alias normalizer_normalize

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 71dd44d3b839789639c16a4b6d5b2e4f40703a74 */
* Stub hash: 451d8875edd23e737c147fb9aab37aa8220d731d */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
@ -42,5 +42,69 @@ static zend_class_entry *register_class_Normalizer(void)
INIT_CLASS_ENTRY(ce, "Normalizer", class_Normalizer_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
zval const_FORM_D_value;
ZVAL_LONG(&const_FORM_D_value, NORMALIZER_FORM_D);
zend_string *const_FORM_D_name = zend_string_init_interned("FORM_D", sizeof("FORM_D") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_FORM_D_name, &const_FORM_D_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_FORM_D_name);
zval const_NFD_value;
ZVAL_LONG(&const_NFD_value, NORMALIZER_NFD);
zend_string *const_NFD_name = zend_string_init_interned("NFD", sizeof("NFD") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_NFD_name, &const_NFD_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_NFD_name);
zval const_FORM_KD_value;
ZVAL_LONG(&const_FORM_KD_value, NORMALIZER_FORM_KD);
zend_string *const_FORM_KD_name = zend_string_init_interned("FORM_KD", sizeof("FORM_KD") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_FORM_KD_name, &const_FORM_KD_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_FORM_KD_name);
zval const_NFKD_value;
ZVAL_LONG(&const_NFKD_value, NORMALIZER_NFKD);
zend_string *const_NFKD_name = zend_string_init_interned("NFKD", sizeof("NFKD") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_NFKD_name, &const_NFKD_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_NFKD_name);
zval const_FORM_C_value;
ZVAL_LONG(&const_FORM_C_value, NORMALIZER_FORM_C);
zend_string *const_FORM_C_name = zend_string_init_interned("FORM_C", sizeof("FORM_C") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_FORM_C_name, &const_FORM_C_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_FORM_C_name);
zval const_NFC_value;
ZVAL_LONG(&const_NFC_value, NORMALIZER_NFC);
zend_string *const_NFC_name = zend_string_init_interned("NFC", sizeof("NFC") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_NFC_name, &const_NFC_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_NFC_name);
zval const_FORM_KC_value;
ZVAL_LONG(&const_FORM_KC_value, NORMALIZER_FORM_KC);
zend_string *const_FORM_KC_name = zend_string_init_interned("FORM_KC", sizeof("FORM_KC") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_FORM_KC_name, &const_FORM_KC_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_FORM_KC_name);
zval const_NFKC_value;
ZVAL_LONG(&const_NFKC_value, NORMALIZER_NFKC);
zend_string *const_NFKC_name = zend_string_init_interned("NFKC", sizeof("NFKC") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_NFKC_name, &const_NFKC_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_NFKC_name);
#if U_ICU_VERSION_MAJOR_NUM >= 56
zval const_FORM_KC_CF_value;
ZVAL_LONG(&const_FORM_KC_CF_value, NORMALIZER_FORM_KC_CF);
zend_string *const_FORM_KC_CF_name = zend_string_init_interned("FORM_KC_CF", sizeof("FORM_KC_CF") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_FORM_KC_CF_name, &const_FORM_KC_CF_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_FORM_KC_CF_name);
#endif
#if U_ICU_VERSION_MAJOR_NUM >= 56
zval const_NFKC_CF_value;
ZVAL_LONG(&const_NFKC_CF_value, NORMALIZER_NFKC_CF);
zend_string *const_NFKC_CF_name = zend_string_init_interned("NFKC_CF", sizeof("NFKC_CF") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_NFKC_CF_name, &const_NFKC_CF_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_NFKC_CF_name);
#endif
return class_entry;
}

View File

@ -12,6 +12,7 @@
+----------------------------------------------------------------------+
*/
#include "normalizer.h"
#include "normalizer_class.h"
#include "php_intl.h"
#include "normalizer_arginfo.h"

View File

@ -36,7 +36,6 @@
#include "msgformat/msgformat_class.h"
#include "normalizer/normalizer.h"
#include "normalizer/normalizer_class.h"
#include "locale/locale.h"
@ -159,9 +158,6 @@ PHP_MINIT_FUNCTION( intl )
/* Register 'Normalizer' PHP class */
normalizer_register_Normalizer_class( );
/* Expose Normalizer constants to PHP scripts */
normalizer_register_constants( INIT_FUNC_ARGS_PASSTHRU );
/* Register 'Locale' PHP class */
locale_register_Locale_class( );