php: Fix overloaded directed methods with non-void return
We were treating such methods like constructors and assigning to the internal _cPtr, which just seems bizarrely wrong. Fixes #1900
This commit is contained in:
parent
57cb95318a
commit
2e7da86b2c
4 changed files with 34 additions and 3 deletions
|
|
@ -47,5 +47,14 @@ public:
|
|||
virtual void notover(int *p) const {}
|
||||
};
|
||||
|
||||
%}
|
||||
class OverloadedGetSet
|
||||
{
|
||||
int v;
|
||||
public:
|
||||
OverloadedGetSet() : v(42) { }
|
||||
virtual ~OverloadedGetSet() { }
|
||||
virtual int rw() const { return v; }
|
||||
virtual void rw(int new_v) { v = new_v; }
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
18
Examples/test-suite/php/director_overload_runme.php
Normal file
18
Examples/test-suite/php/director_overload_runme.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_overload.php";
|
||||
|
||||
check::functions(array('new_overloadedClass','new_overloadedPointers','new_overloadedGetSet','overloadedclass_method1','overloadedclass_method3','overloadedclass_method2','overloadedpointers_method','overloadedpointers_notover','overloadedgetset_rw'));
|
||||
|
||||
check::classes(array('OverloadedClass','OverloadedPointers','OverloadedGetSet'));
|
||||
check::globals(array());
|
||||
|
||||
$o = new OverloadedGetSet;
|
||||
check::equal($o->rw(), 42, "get_set() initial value not 42");
|
||||
check::equal($o->rw(7), null, "get_set() failed to set");
|
||||
check::equal($o->rw(), 7, "get_set() didn't return back set value");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue