From 7dcebde684487facf60ac63550e6f9093f30ec6d Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Sun, 7 Jan 2007 06:16:57 +0000 Subject: [PATCH] Add add_property_zstr(l)(_ex)() --- Zend/zend_API.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ Zend/zend_API.h | 5 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 920c21c879..504d358bef 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1727,6 +1727,50 @@ ZEND_API int add_utf8_property_zval_ex(zval *arg, char *key, uint key_len, zval return SUCCESS; } +ZEND_API int add_property_zstr_ex(zval *arg, char *key, uint key_len, zend_uchar type, zstr str, int duplicate TSRMLS_DC) +{ + zval *tmp; + zval *z_key; + + if (type == IS_UNICODE) { + MAKE_STD_ZVAL(tmp); + ZVAL_UNICODE(tmp, str.u, duplicate); + } else { + MAKE_STD_ZVAL(tmp); + ZVAL_STRING(tmp, str.s, duplicate); + } + + MAKE_STD_ZVAL(z_key); + ZVAL_ASCII_STRINGL(z_key, key, key_len-1, 1); + + Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC); + zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ + zval_ptr_dtor(&z_key); + return SUCCESS; +} + +ZEND_API int add_property_zstrl_ex(zval *arg, char *key, uint key_len, zend_uchar type, zstr str, uint length, int duplicate TSRMLS_DC) +{ + zval *tmp; + zval *z_key; + + if (type == IS_UNICODE) { + MAKE_STD_ZVAL(tmp); + ZVAL_UNICODEL(tmp, str.u, length, duplicate); + } else { + MAKE_STD_ZVAL(tmp); + ZVAL_STRINGL(tmp, str.s, length, duplicate); + } + + MAKE_STD_ZVAL(z_key); + ZVAL_ASCII_STRINGL(z_key, key, key_len-1, 1); + + Z_OBJ_HANDLER_P(arg, write_property)(arg, z_key, tmp TSRMLS_CC); + zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ + zval_ptr_dtor(&z_key); + return SUCCESS; +} + ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC) { int name_len; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index c8c73a25a7..2b09f93d52 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1467,6 +1467,8 @@ ZEND_API int add_property_unicode_ex(zval *arg, char *key, uint key_len, UChar * ZEND_API int add_property_unicodel_ex(zval *arg, char *key, uint key_len, UChar *str, uint length, int duplicate TSRMLS_DC); ZEND_API int add_property_utf8_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate TSRMLS_DC); ZEND_API int add_property_utf8_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate TSRMLS_DC); +ZEND_API int add_property_zstr_ex(zval *arg, char *key, uint key_len, zend_uchar type, zstr str, int duplicate TSRMLS_DC); +ZEND_API int add_property_zstrl_ex(zval *arg, char *key, uint key_len, zend_uchar type, zstr str, uint length, int duplicate TSRMLS_DC); #define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key)+1, __n TSRMLS_CC) #define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key) + 1 TSRMLS_CC) @@ -1484,7 +1486,8 @@ ZEND_API int add_property_utf8_stringl_ex(zval *arg, char *key, uint key_len, ch #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key)+1, __value TSRMLS_CC) #define add_property_unicode(__arg, __key, __str, __duplicate) add_property_unicode_ex(__arg, __key, strlen(__key)+1, __str, __duplicate TSRMLS_CC) #define add_property_unicodel(__arg, __key, __str, __length, __duplicate) add_property_unicodel_ex(__arg, __key, strlen(__key)+1, __str, __length, __duplicate TSRMLS_CC) - +#define add_property_zstr(__arg, __key, __type, __str, __duplicate) add_property_zstr_ex(__arg, __key, strlen(__key)+1, __type, __str, __duplicate TSRMLS_CC) +#define add_property_zstrl(__arg, __key, __type, __str, __length, __duplicate) add_property_zstrl_ex(__arg, __key, strlen(__key)+1, __type, __str, __length, __duplicate TSRMLS_CC) ZEND_API int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC); ZEND_API int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, zend_uint param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC); -- 2.50.1