HashTable *ht = Z_ARRVAL_P(obj);
if (is_associative_array(ht)) {
std::unordered_map<std::string, Directive *> my_map;
- for (zend_hash_internal_pointer_reset(ht); zend_hash_has_more_elements(ht) == SUCCESS; zend_hash_move_forward(ht)) {
- char *str_key;
- ulong num_key;
- zend_hash_get_current_key(ht, &str_key, &num_key, 0);
-
+ zend_string *str_key;
+ zval *zv;
+ ulong num_key;
+ ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) {
std::string key;
- if (zend_hash_get_current_key_type(ht) == HASH_KEY_IS_STRING) {
- key = str_key;
+ if (str_key) {
+ key.assign(str_key->val, str_key->len);
} else {
char buf[32];
sprintf(buf, "%lu", num_key);
key = buf;
}
- zval **data;
- zend_hash_get_current_data(ht, (void **)&data);
- my_map.insert(make_pair(key, convert_php_objects_to_directive(*data)));
- }
+ my_map.insert(make_pair(key, convert_php_objects_to_directive(zv)));
+ } ZEND_HASH_FOREACH_END();
return new Substitute(my_map);
} else {
std::vector<Directive *> subdirectives;
for (unsigned i = 0; i < ht->nNumOfElements; ++i) {
- zval **data;
- zend_hash_index_find(ht, i, (void **)&data);
- subdirectives.push_back(convert_php_objects_to_directive(*data));
+ zval *data = zend_hash_index_find(ht, i);
+ subdirectives.push_back(convert_php_objects_to_directive(data));
}
return new Clone(subdirectives);
}
break;
}
case IS_STRING: {
- char *str = Z_STRVAL_P(obj);
+ std::string str(Z_STRVAL_P(obj), Z_STRLEN_P(obj));
return new Replace(str);
}
case IS_LONG: {
}
return new ReplaceInclude(xmlCopyDoc((*doc)->ptr, 1));
}
+ case IS_REFERENCE:
+ return convert_php_objects_to_directive(&Z_REF_P(obj)->val);
case IS_NULL:
return new Replace { "" };
default:
%}
%typemap(in) Directive* {
- $1 = convert_php_objects_to_directive(*$input);
+ $1 = convert_php_objects_to_directive(&$input);
}
XmlDocPtrWrapper XML_Template_process_file(const std::string &input_filename, Directive *root_directive, bool clean);