Fills out the array/object-property insert helpers for zend_array, zend_object, and zend_reference.
This adds the following matrix of 18 APIs
add_next_index_T()
add_index_T()
add_assoc_T()
add_assoc_T_ex()
add_property_T()
add_property_T_ex()
Where T in array, object, reference
Converted internal callsites currently doing an explicit object wrap.
- Core:
. Fixed inclusion order for phpize builds on Windows. (cmb)
+ . Added missing hashtable insertion APIs for arr/obj/ref. (Sara)
- FTP:
. Convert resource<ftp> to object \FTPConnection. (Sara)
}
/* }}} */
+ZEND_API void add_assoc_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_ARR(&tmp, arr);
+ zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
+}
+/* }}} */
+
+ZEND_API void add_assoc_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_OBJ(&tmp, obj);
+ zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
+}
+/* }}} */
+
+ZEND_API void add_assoc_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_REF(&tmp, ref);
+ zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp);
+}
+/* }}} */
+
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */
{
zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, value);
}
/* }}} */
+ZEND_API void add_index_array(zval *arg, zend_ulong index, zend_array *arr) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_ARR(&tmp, arr);
+ zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
+}
+/* }}} */
+
+ZEND_API void add_index_object(zval *arg, zend_ulong index, zend_object *obj) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_OBJ(&tmp, obj);
+ zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
+}
+/* }}} */
+
+ZEND_API void add_index_reference(zval *arg, zend_ulong index, zend_reference *ref) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_REF(&tmp, ref);
+ zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp);
+}
+/* }}} */
+
ZEND_API zend_result add_next_index_long(zval *arg, zend_long n) /* {{{ */
{
zval tmp;
}
/* }}} */
+ZEND_API zend_result add_next_index_array(zval *arg, zend_array *arr) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_ARR(&tmp, arr);
+ return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE;
+}
+/* }}} */
+
+ZEND_API zend_result add_next_index_object(zval *arg, zend_object *obj) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_OBJ(&tmp, obj);
+ return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE;
+}
+/* }}} */
+
+ZEND_API zend_result add_next_index_reference(zval *arg, zend_reference *ref) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_REF(&tmp, ref);
+ return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE;
+}
+/* }}} */
+
ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */
{
zval *result;
}
/* }}} */
+ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_ARR(&tmp, arr);
+ add_property_zval_ex(arg, key, key_len, &tmp);
+ zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+}
+/* }}} */
+
+ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_OBJ(&tmp, obj);
+ add_property_zval_ex(arg, key, key_len, &tmp);
+ zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+}
+/* }}} */
+
+ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref) /* {{{ */
+{
+ zval tmp;
+
+ ZVAL_REF(&tmp, ref);
+ add_property_zval_ex(arg, key, key_len, &tmp);
+ zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
+}
+/* }}} */
+
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value) /* {{{ */
{
zend_string *str;
ZEND_API void add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
ZEND_API void add_assoc_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
ZEND_API void add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length);
+ZEND_API void add_assoc_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr);
+ZEND_API void add_assoc_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj);
+ZEND_API void add_assoc_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
ZEND_API void add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
#define add_assoc_str(__arg, __key, __str) add_assoc_str_ex(__arg, __key, strlen(__key), __str)
#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
+#define add_assoc_array(__arg, __key, __arr) add_assoc_array_ex(__arg, __key, strlen(__key), __arr)
+#define add_assoc_object(__arg, __key, __obj) add_assoc_object_ex(__arg, __key, strlen(__key), __obj)
+#define add_assoc_reference(__arg, __key, __ref) add_assoc_object_ex(__arg, __key, strlen(__key), __ref)
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n);
ZEND_API void add_index_str(zval *arg, zend_ulong index, zend_string *str);
ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str);
ZEND_API void add_index_stringl(zval *arg, zend_ulong index, const char *str, size_t length);
+ZEND_API void add_index_array(zval *arg, zend_ulong index, zend_array *arr);
+ZEND_API void add_index_object(zval *arg, zend_ulong index, zend_object *obj);
+ZEND_API void add_index_reference(zval *arg, zend_ulong index, zend_reference *ref);
static zend_always_inline zend_result add_index_zval(zval *arg, zend_ulong index, zval *value)
{
ZEND_API zend_result add_next_index_str(zval *arg, zend_string *str);
ZEND_API zend_result add_next_index_string(zval *arg, const char *str);
ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length);
+ZEND_API zend_result add_next_index_array(zval *arg, zend_array *arr);
+ZEND_API zend_result add_next_index_object(zval *arg, zend_object *obj);
+ZEND_API zend_result add_next_index_reference(zval *arg, zend_reference *ref);
static zend_always_inline zend_result add_next_index_zval(zval *arg, zval *value)
{
ZEND_API void add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
ZEND_API void add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
ZEND_API void add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length);
+ZEND_API void add_property_array_ex(zval *arg, const char *key, size_t key_len, zend_array *arr);
+ZEND_API void add_property_object_ex(zval *arg, const char *key, size_t key_len, zend_object *obj);
+ZEND_API void add_property_reference_ex(zval *arg, const char *key, size_t key_len, zend_reference *ref);
ZEND_API void add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
+#define add_property_array(__arg, __key, __arr) add_property_array_ex(__arg, __key, strlen(__key), __arr)
+#define add_property_object(__arg, __key, __obj) add_property_object_ex(__arg, __key, strlen(__key), __obj)
+#define add_property_reference(__arg, __key, __ref) add_property_reference_ex(__arg, __key, strlen(__key), __ref)
#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
zend_ulong obj_addr;
zval *val;
ZEND_HASH_FOREACH_NUM_KEY_VAL(&wm->ht, obj_addr, val) {
+ zend_object *obj = (zend_object*)obj_addr;
zval pair;
- zval obj_zv;
array_init(&pair);
- ZVAL_OBJ_COPY(&obj_zv, (zend_object *) obj_addr);
- add_assoc_zval(&pair, "key", &obj_zv);
+ GC_ADDREF(obj);
+ add_assoc_object(&pair, "key", obj);
Z_TRY_ADDREF_P(val);
add_assoc_zval(&pair, "value", val);
}
/* }}} */
-/* {{{ add_assoc_object */
-static zval *add_assoc_object(zval *arg, char *key, zval *tmp)
+/* {{{ php_imap_hash_add_object */
+static zval *php_imap_hash_add_object(zval *arg, char *key, zval *tmp)
{
HashTable *symtable;
}
/* }}} */
-/* {{{ add_next_index_object */
-static inline zval *add_next_index_object(zval *arg, zval *tmp)
+/* {{{ php_imap_list_add_object */
+static inline zval *php_imap_list_add_object(zval *arg, zval *tmp)
{
HashTable *symtable;
#else
add_property_string(&mboxob, "delimiter", cur->delimiter);
#endif
- add_next_index_object(return_value, &mboxob);
+ php_imap_list_add_object(return_value, &mboxob);
cur=cur->next;
}
mail_free_foblist(&IMAPG(imap_folder_objects), &IMAPG(imap_folder_objects_tail));
#else
add_property_string(&mboxob, "delimiter", cur->delimiter);
#endif
- add_next_index_object(return_value, &mboxob);
+ php_imap_list_add_object(return_value, &mboxob);
cur=cur->next;
}
mail_free_foblist (&IMAPG(imap_sfolder_objects), &IMAPG(imap_sfolder_objects_tail));
if (addresstmp->adl) {
add_property_string(&tovals, "adl", addresstmp->adl);
}
- add_next_index_object(return_value, &tovals);
+ php_imap_list_add_object(return_value, &tovals);
} while ((addresstmp = addresstmp->next));
mail_free_envelope(&env);
object_init(&dparam);
add_property_string(&dparam, "attribute", dpar->attribute);
add_property_string(&dparam, "value", dpar->value);
- add_next_index_object(&dparametres, &dparam);
+ php_imap_list_add_object(&dparametres, &dparam);
} while ((dpar = dpar->next));
- add_assoc_object(return_value, "dparameters", &dparametres);
+ php_imap_hash_add_object(return_value, "dparameters", &dparametres);
} else {
add_property_long(return_value, "ifdparameters", 0);
}
add_property_string(¶m, "value", par->value);
}
- add_next_index_object(¶metres, ¶m);
+ php_imap_list_add_object(¶metres, ¶m);
} while ((par = par->next));
} else {
object_init(¶metres);
add_property_long(return_value, "ifparameters", 0);
}
- add_assoc_object(return_value, "parameters", ¶metres);
+ php_imap_hash_add_object(return_value, "parameters", ¶metres);
}
/* }}} */
add_property_long(&myoverview, "seen", elt->seen);
add_property_long(&myoverview, "draft", elt->draft);
add_property_long(&myoverview, "udate", mail_longdate(elt));
- add_next_index_object(return_value, &myoverview);
+ php_imap_list_add_object(return_value, &myoverview);
}
}
}
if (addresstmp->adl) add_property_string(&tmpvals, "adl", addresstmp->adl);
if (addresstmp->mailbox) add_property_string(&tmpvals, "mailbox", addresstmp->mailbox);
if (addresstmp->host) add_property_string(&tmpvals, "host", addresstmp->host);
- add_next_index_object(paddress, &tmpvals);
+ php_imap_list_add_object(paddress, &tmpvals);
} while ((addresstmp = addresstmp->next));
return fulladdress;
}
if (fulladdress) {
add_property_str(myzvalue, "toaddress", fulladdress);
}
- add_assoc_object(myzvalue, "to", &paddress);
+ php_imap_hash_add_object(myzvalue, "to", &paddress);
}
if (en->from) {
if (fulladdress) {
add_property_str(myzvalue, "fromaddress", fulladdress);
}
- add_assoc_object(myzvalue, "from", &paddress);
+ php_imap_hash_add_object(myzvalue, "from", &paddress);
}
if (en->cc) {
if (fulladdress) {
add_property_str(myzvalue, "ccaddress", fulladdress);
}
- add_assoc_object(myzvalue, "cc", &paddress);
+ php_imap_hash_add_object(myzvalue, "cc", &paddress);
}
if (en->bcc) {
if (fulladdress) {
add_property_str(myzvalue, "bccaddress", fulladdress);
}
- add_assoc_object(myzvalue, "bcc", &paddress);
+ php_imap_hash_add_object(myzvalue, "bcc", &paddress);
}
if (en->reply_to) {
if (fulladdress) {
add_property_str(myzvalue, "reply_toaddress", fulladdress);
}
- add_assoc_object(myzvalue, "reply_to", &paddress);
+ php_imap_hash_add_object(myzvalue, "reply_to", &paddress);
}
if (en->sender) {
if (fulladdress) {
add_property_str(myzvalue, "senderaddress", fulladdress);
}
- add_assoc_object(myzvalue, "sender", &paddress);
+ php_imap_hash_add_object(myzvalue, "sender", &paddress);
}
if (en->return_path) {
if (fulladdress) {
add_property_str(myzvalue, "return_pathaddress", fulladdress);
}
- add_assoc_object(myzvalue, "return_path", &paddress);
+ php_imap_hash_add_object(myzvalue, "return_path", &paddress);
}
}
/* }}} */
object_init(&dparam);
add_property_string(&dparam, "attribute", dpar->attribute);
add_property_string(&dparam, "value", dpar->value);
- add_next_index_object(&dparametres, &dparam);
+ php_imap_list_add_object(&dparametres, &dparam);
} while ((dpar = dpar->next));
- add_assoc_object(arg, "dparameters", &dparametres);
+ php_imap_hash_add_object(arg, "dparameters", &dparametres);
} else {
add_property_long(arg, "ifdparameters", 0);
}
add_property_string(¶m, "value", par->value);
}
- add_next_index_object(¶metres, ¶m);
+ php_imap_list_add_object(¶metres, ¶m);
} while ((par = par->next));
} else {
object_init(¶metres);
add_property_long(arg, "ifparameters", 0);
}
- add_assoc_object(arg, "parameters", ¶metres);
+ php_imap_hash_add_object(arg, "parameters", ¶metres);
/* multipart message ? */
if (body->type == TYPEMULTIPART) {
for (part = body->CONTENT_PART; part; part = part->next) {
object_init(¶m);
_php_imap_add_body(¶m, &part->body);
- add_next_index_object(¶metres, ¶m);
+ php_imap_list_add_object(¶metres, ¶m);
}
- add_assoc_object(arg, "parts", ¶metres);
+ php_imap_hash_add_object(arg, "parts", ¶metres);
}
/* encapsulated message ? */
array_init(¶metres);
object_init(¶m);
_php_imap_add_body(¶m, body);
- add_next_index_object(¶metres, ¶m);
- add_assoc_object(arg, "parts", ¶metres);
+ php_imap_list_add_object(¶metres, ¶m);
+ php_imap_hash_add_object(arg, "parts", ¶metres);
}
}
/* }}} */
if (SPL_G(autoload_functions)) {
ZEND_HASH_FOREACH_PTR(SPL_G(autoload_functions), alfi) {
if (alfi->closure) {
- zval obj_zv;
- ZVAL_OBJ_COPY(&obj_zv, alfi->closure);
- add_next_index_zval(return_value, &obj_zv);
+ GC_ADDREF(alfi->closure);
+ add_next_index_object(return_value, alfi->closure);
} else if (alfi->func_ptr->common.scope) {
zval tmp;
array_init(&tmp);
if (alfi->obj) {
- zval obj_zv;
- ZVAL_OBJ_COPY(&obj_zv, alfi->obj);
- add_next_index_zval(&tmp, &obj_zv);
+ GC_ADDREF(alfi->obj);
+ add_next_index_object(&tmp, alfi->obj);
} else {
add_next_index_str(&tmp, zend_string_copy(alfi->ce->name));
}