summaryrefslogtreecommitdiff
path: root/Examples/test-suite/php_iterator.i
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/php_iterator.i')
-rw-r--r--Examples/test-suite/php_iterator.i20
1 files changed, 20 insertions, 0 deletions
diff --git a/Examples/test-suite/php_iterator.i b/Examples/test-suite/php_iterator.i
new file mode 100644
index 000000000..43ab68b55
--- /dev/null
+++ b/Examples/test-suite/php_iterator.i
@@ -0,0 +1,20 @@
+/* php_iterator.i - PHP-specific testcase for wrapping to a PHP Iterator */
+%module php_iterator
+
+%typemap("phpinterfaces") MyIterator "Iterator";
+
+%inline %{
+
+class MyIterator {
+ int i, from, to;
+public:
+ MyIterator(int from_, int to_)
+ : i(from_), from(from_), to(to_) { }
+ void rewind() { i = from; }
+ bool valid() const { return i != to; }
+ int key() const { return i - from; }
+ int current() const { return i; }
+ void next() { ++i; }
+};
+
+%}