]> git.sesse.net Git - xml-template/commitdiff
Add a proper wrapper for php5-swig, which also makes attribute[23] pass. All tests...
authorsgunderson@bigfoot.com <>
Fri, 23 Sep 2011 00:16:21 +0000 (02:16 +0200)
committersgunderson@bigfoot.com <>
Fri, 23 Sep 2011 00:16:21 +0000 (02:16 +0200)
12 files changed:
php5-swig/attribute-empty.php
php5-swig/attribute.php
php5-swig/attribute2.php
php5-swig/attribute3.php
php5-swig/clone.php
php5-swig/include.php
php5-swig/namespace.php
php5-swig/namespace2.php
php5-swig/passthru.php
php5-swig/simple.php
php5-swig/structure.php
php5-swig/xml-template.php [new file with mode: 0644]

index 98555a24909ac8ee7c8c1e1070581f03a49ae9c4..ba4941ec384e0101fa3af5b623749813fc2aa3e4 100644 (file)
@@ -1,6 +1,5 @@
 <?php
-
-dl("XML_Template_SWIG.so");
+include("xml-template.php");
 
 # NULL values are ignored, but having one helps pointing out that
 # the array given is non-associative
index 003cf2b68b5c7e19792eb749e55449b21ab0d30a..cc0656148159d1f3f3325e2ec3153711851f2402 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/clone.xml', array(
        'color' => 'red',
        '#things' => array(
index 020288525849776491dd9a5be688936b2ba75445..95a6970bd19c0cb376085f908dfe67ad3653553a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/clone.xml', array(
        'color' => 'blue',
        '#things' => XML_Template_alternate('li/class', array(
index 215621536aab1f335cb388a5033e87b3b10a1abf..74920fd72172d67279d7993d5f91b7b7263c50a4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/clone.xml', array(
        'color' => 'blue',
        '#things' => XML_Template_alternate('li/class', array(
index 1193ea08e482c88b58ab060caaf80cbe670252c1..ab0ed7a31e4d73aebb06a497fdd9c2d2f57456cc 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/clone.xml', array( 
        'color' => 'blue',
        '#things' => array(
index 92b71d6dca4c07e897251b7f7b49df290bfdf24b..cc98dde7bfe15a924f5f53dd3c4ac132b6e8d28f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/included.xml', array(
        'color' => 'red'
 ), false);
index 9a653dc3b4adb85a4d188d3ff5799173197267c9..b5c854705359d8661df09e7f1a78677f65595dee 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/namespace.xml', array( 
        'title' => 'Namespace tests',
        '#hello' => 'Hello world!',
index 04622cf99ee036a339c6e349579c748fdf6e1d20..3111890dc710c2edbbbeaffe85f0bb8d85165ea5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/namespace2.xml', array( 
        'title' => 'Namespace tests',
        '#hello' => 'Replaced.',
index 2496b18c8759ec5e682dd75775c11a498fc93d1d..c51e1e1f60787011815678f7f83952c8014c354a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/passthru.xml', array(), true);
 output_to_fd($doc, 1);
 
index a5b7f04ff1a7ea5092166cb77da785dbcae1e294..33a512d8711645586a618e5c93863b8c5f264f37 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/simple.xml', array( 
        'title' => 'A very basic example',
        '#hello' => 'Hello world!'
index b27a040d7697a4001df18fabcd7db32f89b3d186..32399ddddf461a7362bcd53260b579a6b52883f2 100644 (file)
@@ -1,6 +1,6 @@
 <?php
+include("xml-template.php");
 
-dl("XML_Template_SWIG.so");
 $doc = XML_Template_process_file('../xml/structure.xml', array(
        '#outer' => array(
                array( '#inner' => 'One' ),
diff --git a/php5-swig/xml-template.php b/php5-swig/xml-template.php
new file mode 100644 (file)
index 0000000..289b9c7
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+include("XML_Template_SWIG.php");
+
+# FIXME: use varargs here
+function XML_Template_alternate($tag, $array, $elems)
+{
+       $num = count($elems);
+
+       for ($i = 0, $j = 0; $i < count($array); $i++) {
+               if (isset($array[$i])) {
+                       $array[$i][$tag] = $elems[$j++ % $num];
+               }
+       }
+
+       return $array;
+}
+?>