]> granicus.if.org Git - php/commitdiff
Been a long day..
authorAndrei Zmievski <andrei@php.net>
Mon, 8 May 2006 23:01:20 +0000 (23:01 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 8 May 2006 23:01:20 +0000 (23:01 +0000)
ext/unicode/php_property.h
ext/unicode/property.c
ext/unicode/unicode.c

index a58431307b020694a0027683e3d845c8e6361a9b..c72eb8d4dfe8399dc433ff862bf025d918e73b03 100644 (file)
@@ -80,6 +80,8 @@ PHP_FUNCTION(char_get_property_min_value);
 PHP_FUNCTION(char_get_property_max_value);
 PHP_FUNCTION(char_get_property_name);
 PHP_FUNCTION(char_get_property_from_name);
+PHP_FUNCTION(char_get_property_value_name);
+PHP_FUNCTION(char_get_property_value_from_name);
 
 #endif /* PHP_PROPERTY_H */
 
index 689b853b10c5068796857b1ebcfe896b967a5d76..dad6e9b34846cdcb44b213f08b1c9ce9b71880fd 100644 (file)
@@ -548,7 +548,6 @@ PHP_FUNCTION(char_get_property_name)
        } else {
                RETURN_FALSE;
        }
-
 }
 
 PHP_FUNCTION(char_get_property_from_name)
@@ -581,6 +580,60 @@ PHP_FUNCTION(char_get_property_from_name)
        RETURN_LONG(prop);
 }
 
+PHP_FUNCTION(char_get_property_value_name)
+{
+       long             prop;
+       long             value;
+       long             name_choice = U_LONG_PROPERTY_NAME;
+       const char      *name;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|l", &prop, &value, &name_choice) == FAILURE) {
+               return;
+       }
+
+       if (name_choice < 0) {
+               name_choice = U_LONG_PROPERTY_NAME;
+       }
+
+       name = u_getPropertyValueName((UProperty) prop, (int32_t) value, (UPropertyNameChoice) name_choice);
+       if (name) {
+               RETURN_ASCII_STRING((char *)name, ZSTR_DUPLICATE);
+       } else {
+               RETURN_FALSE;
+       }
+}
+
+PHP_FUNCTION(char_get_property_value_from_name)
+{
+       long            prop;
+       void       *name;
+       int                     name_len;
+       zend_uchar      name_type;
+       char       *buf;
+       long            value;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lt", &prop, &name, &name_len, &name_type) == FAILURE) {
+               return;
+       }
+
+       if (name_type == IS_UNICODE) {
+               buf = zend_unicode_to_ascii(name, name_len TSRMLS_CC);
+               if (buf == NULL) {
+                       php_error(E_WARNING, "Property value name has to consist only of ASCII characters");
+                       RETURN_FALSE;
+               }
+       } else {
+               buf = (char *) name;
+       }
+
+       value = u_getPropertyValueEnum((UProperty)prop, buf);
+       if (name_type == IS_UNICODE) {
+               efree(buf);
+       }
+
+       RETURN_LONG(value);
+}
+
 /* }}} */
 
 /*
index 2e58d97ddc5f9d20d56eb1ab18d4e82305f5cf20..b80f4d6942a19ee55aa5f2a68aea0fcacfffdded 100644 (file)
@@ -292,6 +292,8 @@ zend_function_entry unicode_functions[] = {
        PHP_FE(char_get_property_max_value, NULL)
        PHP_FE(char_get_property_name,          NULL)
        PHP_FE(char_get_property_from_name,     NULL)
+       PHP_FE(char_get_property_value_name, NULL)
+       PHP_FE(char_get_property_value_from_name, NULL)
 
        { NULL, NULL, NULL }
 };