]> git.sesse.net Git - xml-template/blobdiff - php5-swig/xml-template.swig
Leak a little less memory in php5-swig.
[xml-template] / php5-swig / xml-template.swig
index d395ac20a72cc097ed7335b8dde68b7f6af1776a..2feceba72843fada4f12226cfd7acf6ff36361cf 100644 (file)
@@ -44,7 +44,13 @@ Directive* convert_php_objects_to_directive(zval *obj)
                        }
                        return new Substitute(my_map);
                } else {
-                       printf("ARRAY\n");
+                       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));
+                       }
+                       return new Clone(subdirectives);
                }
                break;
        }
@@ -52,6 +58,8 @@ Directive* convert_php_objects_to_directive(zval *obj)
                char *str = Z_STRVAL_P(obj);
                return new Replace(str);
        }
+       case IS_NULL:
+               return NULL;
        default:
                printf("WARNING: Unknown type %d!\n", Z_TYPE_P(obj));
                break;
@@ -60,12 +68,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);