X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=php5-swig%2Fxml-template.swig;h=a2dd2d1926c6925149c9d41e05c327bab3a8684e;hb=8ad17ad06612ee08a69572186858be074b0c5c99;hp=5a560cee6883bf4bce903964fe653ee2755a71c5;hpb=0ccbc5e506ee3ed6bcc77bc4d6cdbde9791e8ad5;p=xml-template diff --git a/php5-swig/xml-template.swig b/php5-swig/xml-template.swig index 5a560ce..a2dd2d1 100644 --- a/php5-swig/xml-template.swig +++ b/php5-swig/xml-template.swig @@ -10,9 +10,7 @@ bool is_associative_array(HashTable *ht) return true; } for (unsigned i = 0; i < ht->nNumOfElements; ++i) { - char buf[32]; - sprintf(buf, "%u", i); - if (!zend_hash_exists(ht, buf, strlen(buf))) { + if (!zend_hash_index_exists(ht, i)) { return true; } } @@ -46,7 +44,13 @@ Directive* convert_php_objects_to_directive(zval *obj) } return new Substitute(my_map); } else { - printf("ARRAY\n"); + std::vector 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)); + } + return new Clone(subdirectives); } break; } @@ -54,6 +58,15 @@ Directive* convert_php_objects_to_directive(zval *obj) char *str = Z_STRVAL_P(obj); return new Replace(str); } + case IS_RESOURCE: { + xmlDocPtr *doc; + if (SWIG_ConvertPtr(obj, (void **)&doc, SWIGTYPE_p_xmlDocPtr, 0) < 0 || doc == NULL) { + return NULL; + } + return new ReplaceInclude(xmlCopyDoc(*doc, 1)); + } + case IS_NULL: + return NULL; default: printf("WARNING: Unknown type %d!\n", Z_TYPE_P(obj)); break; @@ -62,12 +75,19 @@ Directive* convert_php_objects_to_directive(zval *obj) return NULL; } +xmlDocPtr XML_Template_process_file(const char *input_filename, Directive *root_directive, bool clean) +{ + xmlDocPtr ret = process_file(input_filename, root_directive, clean); + delete root_directive; + return ret; +} + %} %typemap(in) Directive* { $1 = convert_php_objects_to_directive(*$input); } -xmlDocPtr process_file(const char *input_filename, Directive *root_directive, bool clean); +xmlDocPtr XML_Template_process_file(const char *input_filename, Directive *root_directive, bool clean); void output_to_fd_and_free(xmlDocPtr doc, int fd);