[PHP] Add support for specifying any PHP interfaces a wrapped class
implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
This commit is contained in:
parent
e12322df86
commit
1a99212c2c
7 changed files with 79 additions and 0 deletions
20
Examples/test-suite/php_iterator.i
Normal file
20
Examples/test-suite/php_iterator.i
Normal file
|
|
@ -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; }
|
||||
};
|
||||
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue